Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        //private readonly RoleDAL srdal = new RoleDAL();
        //private readonly MenuDAL smdal = new MenuDAL();
        /// <summary>
        /// 得到所有用户
        /// </summary>
        /// <returns></returns>
        public Grid <SysUser> GetList()
        {
            Grid <SysUser> g = new Grid <SysUser>();

            g.total = sysUserDal.GetCount();
            g.rows  = sysUserDal.GetList();

            return(g);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取角色所分配的用户
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public HandleResult <PageModel> GetRoleUserList(string roleId, string page, string limit, string searchstr)
        {
            var handleResult = new HandleResult <PageModel>();
            var PageModel    = new PageModel();
            var urRelateds   = sysUrRelatedDAL.GetModels(t => t.RoleId.Equals(roleId)).ToList();
            //构建条件
            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)DeleteSign.Sing_Deleted) &&
                                                            urRelateds.Any(x => x.UserId == t.UserId);

            PageModel.RowCount = sysUserDAL.GetCount(expression);
            var list = sysUserDAL.GetModelsByPage(Convert.ToInt32(limit), Convert.ToInt32(page), false, t => t.CreateTime, expression).ToList();

            PageModel.Data    = Mapper.Map <List <SysUserDto> >(list);
            handleResult.Data = PageModel;
            return(handleResult);
        }