分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-06-21 11ff4d231e12aa7f7cd2627df5f79b6d2bed5906
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_Core/Infrastructure/DictionaryHandler.cs
@@ -24,19 +24,36 @@
            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>
@@ -45,7 +62,7 @@
        /// <returns></returns>
        public static string GetRolesSql(string originalSql)
        {
            if (UserContext.Current.IsSuperAdmin)
            {
                return originalSql;
@@ -54,15 +71,17 @@
            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;
        }
    }