Skip to content

Commit

Permalink
feat: tenant data perm redis key
Browse files Browse the repository at this point in the history
  • Loading branch information
suyuan32 committed Jul 10, 2024
1 parent d5eb61a commit d13571c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions orm/ent/entctx/datapermctx/data_perm_ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,18 @@ func GetRoleScopeDataPermRedisKey(roleCodes []string) string {
func GetSubDeptDataPermRedisKey(departmentId uint64) string {
return fmt.Sprintf("%sDEPT:%d:SubDept", config.RedisDataPermissionPrefix, departmentId)
}

// GetTenantRoleCustomDeptDataPermRedisKey returns the key to store tenant's role custom department data into redis
func GetTenantRoleCustomDeptDataPermRedisKey(roleCodes []string, tenantId uint64) string {
return fmt.Sprintf("%s:%d:ROLE:%s:CustomDept", config.RedisDataPermissionPrefix, tenantId, strings.Join(roleCodes, ","))
}

// GetTenantRoleScopeDataPermRedisKey returns the key to store tenant's role data scope into redis
func GetTenantRoleScopeDataPermRedisKey(roleCodes []string, tenantId uint64) string {
return fmt.Sprintf("%s:%d:ROLE:%s:Scope", config.RedisDataPermissionPrefix, tenantId, strings.Join(roleCodes, ","))
}

// GetTenantSubDeptDataPermRedisKey returns the key to store tenant's sub department data into redis
func GetTenantSubDeptDataPermRedisKey(departmentId uint64, tenantId uint64) string {
return fmt.Sprintf("%s:%d:DEPT:%d:SubDept", config.RedisDataPermissionPrefix, tenantId, departmentId)
}

0 comments on commit d13571c

Please sign in to comment.