Ejemplo n.º 1
0
        /// <summary>
        /// 根据筛选条件 (获取分页组件)
        /// </summary>
        /// <param name="userQuery">筛选条件</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">显示条数</param>
        /// <returns></returns>
        public PagingDataSet <Roles> GetRoles(RolesQuery rolesQuery, int pageIndex, int pageSize)
        {
            int    totalCount = 0;
            int    totalPage  = 0;
            string whereSql   = string.Empty;
            string orderBy    = string.Empty;

            HandleQueryByString(rolesQuery, out whereSql);
            HandleOrderByEunm(rolesQuery, out orderBy);
            return(GetPageListByCache <string>(pageIndex, pageSize, out totalCount, out totalPage, whereSql, orderBy, i => i.Rolename));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据枚举排序
        /// </summary>
        /// <param name="rolesQuery"></param>
        /// <param name="order"></param>
        private void HandleOrderByEunm(RolesQuery rolesQuery, out string order)
        {
            order = "";
            switch (rolesQuery.RoleSortBy)
            {
            case RoleSortBy.Rolename:
                order = "rolename ASC";
                break;

            case RoleSortBy.Rolename_Desc:
                order = "rolename DESC";
                break;

            case RoleSortBy.IsEnabled:
                order = "is_enabled ASC";
                break;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 查询角色
 /// </summary>
 /// <param name="rolesQuery">查询参数</param>
 /// <param name="sql"></param>
 private void HandleQueryByString(RolesQuery rolesQuery, out string sql)
 {
     sql = "1=1 ";
     if (!string.IsNullOrWhiteSpace(rolesQuery.Keyword))
     {
         sql += $"and (rolename like \"%{rolesQuery.Keyword}%\" or friendly_rolename like \"%{rolesQuery.Keyword}%\") ";
     }
     if (rolesQuery.IsEnabled.HasValue)
     {
         sql += $"and is_enabled = {rolesQuery.IsEnabled} ";
     }
     if (rolesQuery.IsPublic.HasValue)
     {
         sql += $"and is_public = {rolesQuery.IsPublic} ";
     }
     if (rolesQuery.IsBuiltin.HasValue)
     {
         sql += $"and is_builtin = {rolesQuery.IsBuiltin} ";
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 根据筛选条件 (获取分页组件)
 /// </summary>
 /// <param name="userQuery">筛选条件</param>
 /// <param name="pageIndex">页码</param>
 /// <param name="pageSize">显示条数</param>
 /// <returns></returns>
 public PagingDataSet <Roles> GetRoles(RolesQuery rolesQuery, int pageIndex, int pageSize)
 {
     return(rolesRepository.GetRoles(rolesQuery, pageIndex, pageSize));
 }