예제 #1
0
        /// <summary>
        /// 获取用户列表
        /// </summary>
        /// <param name="page">第几页</param>
        /// <param name="limit">页容量</param>
        /// <param name="searchstr">搜索内容</param>
        /// <returns></returns>
        public MessageModel GetUserList(string page, string limit, string searchstr)
        {
            var messageModel = new MessageModel();
            var PageModel    = new PageModel();
            Expression <Func <SysUser, bool> > expression = t => (string.IsNullOrEmpty(searchstr) || t.UserName.Contains(searchstr) ||
                                                                  t.UserNikeName.Contains(searchstr) ||
                                                                  t.UserPhone.Contains(searchstr) ||
                                                                  t.UserQq.Contains(searchstr) ||
                                                                  t.UserWx.Contains(searchstr) ||
                                                                  t.UserEmail.Contains(searchstr)) && t.DeleteSign.Equals((int)SysEnum.Enum_DeleteSign.Sing_Deleted);

            PageModel.RowCount = usersDAL.GetCount(expression);
            int iBeginRow = Convert.ToInt32(limit) * (Convert.ToInt32(page) - 1), iEndRow = Convert.ToInt32(page) * Convert.ToInt32(limit);
            var list = usersDAL.SqlQuery <SysUserDto>($@"                                           
                                    SELECT  T1.*
                                    FROM Sys_User T1
                                    WHERE (T1.UserNikeName LIKE '%{searchstr}%'
                                            OR T1.UserPhone LIKE '%{searchstr}%'
                                            OR T1.UserQq LIKE '%{searchstr}%'
                                            OR T1.UserWx LIKE '%{searchstr}%'
                                            OR T1.UserEmail LIKE '%{searchstr}%')
                                        AND T1.DeleteSign = 1 order by T1.CREATETIME 
                                limit  {iBeginRow} ,  {limit}");

            PageModel.Data    = list;
            messageModel.Data = PageModel;
            return(messageModel);
        }
예제 #2
0
        /// <summary>
        /// 获取角色所分配的用户
        /// </summary>
        /// <param name="RoleId"></param>
        /// <returns></returns>
        public MessageModel GetRoleUserList(string RoleId, string page, string limit, string searchstr)
        {
            var messageModel = new MessageModel();
            var PageModel    = new PageModel();
            //var urRelateds = sysUrRelatedDAL.GetModels(t => t.RoleId.Equals(RoleId)).ToList();
            var urRelateds = sysUrRelatedDAL.GetModels(t => t.RoleId.Equals(RoleId));
            Expression <Func <SysUser, bool> > expression = t => (string.IsNullOrEmpty(searchstr) || t.UserName.Contains(searchstr) ||
                                                                  t.UserNikeName.Contains(searchstr) ||
                                                                  t.UserPhone.Contains(searchstr) ||
                                                                  t.UserQq.Contains(searchstr) ||
                                                                  t.UserWx.Contains(searchstr) ||
                                                                  t.UserEmail.Contains(searchstr)) && t.DeleteSign.Equals((int)SysEnum.Enum_DeleteSign.Sing_Deleted) &&
                                                            urRelateds.Any(x => x.UserId == t.UserId);

            PageModel.RowCount = sysUserDAL.GetCount(expression);
            int iBeginRow = Convert.ToInt32(limit) * (Convert.ToInt32(page) - 1), iEndRow = Convert.ToInt32(page) * Convert.ToInt32(limit);
            var paramlist = string.Empty;

            if (urRelateds.Count() > 0)
            {
                paramlist = String.Join("','", urRelateds.Select(t => t.UserId));
            }
            var list = sysUserDAL.SqlQuery <SysUserDto>($@"
                                            SELECT T1.*
                                    FROM Sys_User T1
                                    WHERE (T1.UserNikeName LIKE '%{searchstr}%'
                                            OR T1.UserPhone LIKE '%{searchstr}%'
                                            OR T1.UserQq LIKE '%{searchstr}%'
                                            OR T1.UserWx LIKE '%{searchstr}%'
                                            OR T1.UserEmail LIKE '%{searchstr}%')
                                        AND T1.DeleteSign = 1
                                        AND T1.UserId IN('{paramlist}')
                                      order by T1.CREATETIME
                                limit   {iBeginRow} , {limit}");

            PageModel.Data    = list;
            messageModel.Data = PageModel;
            return(messageModel);
        }