| | |
| | | switch (dicNo) |
| | | { |
| | | case "roles": |
| | | originalSql = GetRolesSql(originalSql); |
| | | break; |
| | | //2020.05.24å¢å ç»å®table表æ¶ï¼è·åææçè§è²å表 |
| | | //注æï¼å¦ææ¯2020.05.24ä¹åè·åçæ°æ®åºèæ¬ |
| | | //请å¨èåã䏿æ¡ç»å®è®¾ç½®ãæ·»å ä¸ä¸ªåå
¸ç¼å·ãt_rolesã,é¤äºåå
¸ç¼å·ï¼å
¶ä»å
容é便填å |
| | | case "t_roles": |
| | | originalSql = GetRolesSql(); |
| | | break; |
| | | case "tree_roles": |
| | | originalSql = GetRolesSql(originalSql); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return originalSql; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 2020.05.24å¢å ç»å®table表æ¶ï¼è·åææçè§è²å表 |
| | | /// </summary> |
| | | /// <param name="context"></param> |
| | | /// <param name="originalSql"></param> |
| | | /// <returns></returns> |
| | | public static string GetRolesSql() |
| | | { |
| | | if (DBType.Name == DbCurrentType.PgSql.ToString()) |
| | | { |
| | | return "SELECT \"Role_Id\" as key,\"RoleName\" as value from Sys_Role"; |
| | | } |
| | | return $@"SELECT Role_Id as 'key',RoleName as 'value' FROM Sys_Role |
| | | WHERE Enable=1 "; |
| | | } |
| | | /// <summary> |
| | | /// è·åè§£å³çæ°æ®æºï¼åªè½çå°èªå·±ä¸ä¸çº§ææè§è² |
| | | /// </summary> |
| | |
| | | /// <returns></returns> |
| | | public static string GetRolesSql(string originalSql) |
| | | { |
| | | |
| | | |
| | | if (UserContext.Current.IsSuperAdmin) |
| | | { |
| | | return originalSql; |
| | |
| | | int currnetRoleId = UserContext.Current.RoleId; |
| | | List<int> roleIds = RoleContext.GetAllChildrenIds(currnetRoleId); |
| | | roleIds.Add(currnetRoleId); |
| | | if (DBType.Name == DbCurrentType.PgSql.ToString()) |
| | | { |
| | | originalSql = $"SELECT \"Role_Id\" as key,\"Role_Id\" as id,\"RoleName\" as value,\"ParentId\" AS parentId from Sys_Role" |
| | | +$" where \"Role_Id\" in ({string.Join(',', roleIds)})"; |
| | | } |
| | | else { |
| | | originalSql= $@"SELECT Role_Id as 'key',Role_Id AS id,ParentId AS parentId,RoleName as 'value' FROM Sys_Role |
| | | WHERE Enable=1 and Role_Id in ({string.Join(',', roleIds)})"; |
| | | } |
| | | //if (DBType.Name == DbCurrentType.PgSql.ToString()) |
| | | //{ |
| | | // originalSql = $"SELECT \"Role_Id\" as key,\"Role_Id\" as id,\"RoleName\" as value,\"ParentId\" AS parentId from Sys_Role" |
| | | // +$" where \"Role_Id\" in ({string.Join(',', roleIds)})"; |
| | | //} |
| | | //else { |
| | | // originalSql= $@"SELECT Role_Id as 'key',Role_Id AS id,ParentId AS parentId,RoleName as 'value' FROM Sys_Role |
| | | // WHERE Enable=1 and Role_Id in ({string.Join(',', roleIds)})"; |
| | | //} |
| | | originalSql = $@"SELECT Role_Id as 'key',RoleName as 'value' FROM Sys_Role |
| | | WHERE Enable=1 and Role_Id in ({string.Join(',', roleIds)})"; |
| | | return originalSql; |
| | | } |
| | | } |