public UserList GetAdminUserList(int pageIndex = 1, int pageSize = 10, string order = "")
        {
            var dao         = new UserDao(ConfigurationManager.AppSettings["mysqlConnStr"]);
            var userOpenIds = dao.GetUserOpenIdListByApiLog(pageIndex, pageSize, "and (usertype='普通用户' or usertype is null) ");
            var count       = dao.GetListCount("and (usertype='普通用户' or usertype is null) ");

            var usersExt  = new List <UserExt>();
            var apiLogDao = new ApiLogDao(ConfigurationManager.AppSettings["mysqlConnStr"]);

            userOpenIds.ForEach(openId =>
            {
                if (!string.IsNullOrEmpty(openId))
                {
                    var user = dao.GetUser(openId);

                    var log              = apiLogDao.GetByOpenId(user.openId);
                    UserExt userExt      = new UserExt();
                    userExt.id           = user.id;
                    userExt.openId       = user.openId;
                    userExt.nickName     = user.nickName;
                    userExt.province     = user.province;
                    userExt.city         = user.city;
                    userExt.phone        = user.phone;
                    userExt.sex          = user.sex;
                    userExt.headpic      = user.headpic;
                    userExt.usertype     = user.usertype;
                    userExt.note         = user.note;
                    userExt.expertise    = user.expertise;
                    userExt.verified     = user.verified;
                    userExt.displayinapp = user.displayinapp;
                    userExt.detailimage  = user.detailimage;
                    userExt.createdAt    = user.createdAt;

                    userExt.lastVisitedAt      = apiLogDao.GetLastVisitedTime(user.openId); //log.lastVisitedAt;
                    userExt.visitCountLastWeek = apiLogDao.GetLastWeekCount(user.openId);   //log.visitCountLastWeek;

                    usersExt.Add(userExt);
                }
            });

            if (order == "descend")
            {
                usersExt = usersExt.OrderByDescending(user => user.lastVisitedAt).ToList();
            }
            else if (order == "ascend")
            {
                usersExt = usersExt.OrderBy(user => user.lastVisitedAt).ToList();
            }

            return(new UserList()
            {
                list = usersExt, count = count
            });
        }
예제 #2
0
        public VisitLogList GetApiLogList(int pageIndex = 1, int pageSize = 10)
        {
            List <VisitLog> logs = new List <VisitLog>();
            var             dao  = new ApiLogDao(ConfigurationManager.AppSettings["mysqlConnStr"]);

            logs = dao.GetList(pageIndex, pageSize);

            logs.ForEach(log =>
            {
                log.visitCountLastWeek = dao.GetLastWeekCount(log.openId);
                //log.lastVisitedAt = dao.GetLastVisitedTime(log.openId);
            });

            long count = dao.GetListCount();

            return(new VisitLogList()
            {
                count = count,
                list = logs
            });
        }