Beispiel #1
0
        public async Task <Pager <IQueryable <OrderPay> > > OrderListByUserId(string user_id, int type, string order_id = "0")
        {
            //判断查询参数(组装查询条件)
            Expression <Func <OrderPay, bool> > where_search = LinqUtil.True <OrderPay>();

            where_search = where_search.AndAlso(c => c.user_id == user_id);
            if (type == 1)
            {
                where_search = where_search.AndAlso(c => c.order_delete == 1).AndAlso(c => c.orderdetail_delete == 1);
            }
            if (type == 2)
            {
                where_search = where_search.AndAlso(c => c.order_delete == 1).AndAlso(c => c.orderdetail_delete == 1).AndAlso(c => c.order_paystatus == 1);
            }
            if (type == 3)
            {
                where_search = where_search.AndAlso(c => c.order_delete == 1).AndAlso(c => c.orderdetail_delete == 1).AndAlso(c => c.order_goods == 2);
            }
            if (type == 4)
            {
                where_search = where_search.AndAlso(c => c.order_delete == 1).AndAlso(c => c.orderdetail_delete == 1).AndAlso(c => c.order_id == order_id);
            }
            var data = await orderRepository.OrderListInfo(where_search);

            return(new Pager <IQueryable <OrderPay> >(data.Count(), data));
        }
        public async Task <Pager <IQueryable <CarouselEntity> > > List(CarouselInfo carouselInfo)
        {
            //判断查询参数(组装查询条件)
            Expression <Func <CarouselEntity, bool> > where_search = LinqUtil.True <CarouselEntity>();

            if (!string.IsNullOrEmpty(carouselInfo.carousel_titie))
            {
                where_search = where_search.AndAlso(c => c.carousel_titie.Contains(carouselInfo.carousel_titie));
            }

            if (carouselInfo.disable != -1)
            {
                where_search = where_search.AndAlso(c => c.disable == carouselInfo.disable);
            }

            //调用仓储方法查询分页并且响应给前台
            int total = await carouselRepository.CountAsync(where_search);

            IQueryable <CarouselEntity> carouselEntitys = await carouselRepository.GetPageAllAsync(carouselInfo.pageindex, carouselInfo.pagesize, where_search,
                                                                                                   c => c.createtime, (c => new CarouselEntity
            {
                carousel_id = c.carousel_id,
                carousel_titie = c.carousel_titie,
                carousel_conent = c.carousel_conent,
                carousel_image = c.carousel_image,
                carousel_href = c.carousel_href,
                carousel_sort = c.carousel_sort,
                createtime = c.createtime,
                disable = c.disable,
                disabledesc = c.disabledesc
            }), false);

            return(new Pager <IQueryable <CarouselEntity> >(total, carouselEntitys));
        }
Beispiel #3
0
        public async Task <BaseResult <bool> > UpdatePassword(string user_id, string passwordOld, string passwordNew)
        {
            if (string.IsNullOrEmpty(user_id))
            {
                return(new BaseResult <bool>(808));
            }

            Expression <Func <UserEntity, bool> > where = LinqUtil.True <UserEntity>();
            where = where.AndAlso(c => c.user_id == user_id);
            where = where.AndAlso(c => c.user_pwd == CommonUtil.Md5(passwordOld) && c.disable != 1);

            UserEntity userEntity = await userRepository.GetAsync(where);

            if (userEntity == null)
            {
                return(new BaseResult <bool>(1002, false));
            }

            UserEntity userEntityUpdate = new UserEntity()
            {
                user_id  = user_id,
                user_pwd = CommonUtil.Md5(passwordNew)
            };
            var isTrue = await userRepository.UpdateAsync(userEntityUpdate, true, true, u => u.user_pwd);

            if (isTrue)
            {
                return(new BaseResult <bool>(200, true));
            }
            return(new BaseResult <bool>(201, false));
        }
Beispiel #4
0
        public async Task <Pager <IQueryable <UserDepartRoleInfo> > > List(UserInfo userInfo)
        {
            //判断查询参数(组装查询条件)
            Expression <Func <UserDepartRoleInfo, bool> > where_search = LinqUtil.True <UserDepartRoleInfo>();

            if (!string.IsNullOrEmpty(userInfo.name))
            {
                where_search = RegexUtil.Email(userInfo.name) ? where_search.AndAlso(c => c.user_email == userInfo.name)
                    : where_search.AndAlso(c => c.user_phone == userInfo.name);
            }
            if (userInfo.gender != -1)
            {
                where_search = where_search.AndAlso(c => c.user_gender == userInfo.gender);
            }
            if (userInfo.source != -1)
            {
                where_search = where_search.AndAlso(c => c.source_type == userInfo.source);
            }
            if (userInfo.status != -1)
            {
                where_search = where_search.AndAlso(c => c.disable == userInfo.status);
            }

            //根据条件查询用户表,部门表,用户部门表查询出来用户信息
            int total = 0;
            IQueryable <UserDepartRoleInfo> user_dep_role = await userRepository.getLeftJoinDepRole(where_search,
                                                                                                    userInfo.pageindex, userInfo.pagesize, out total);

            return(new Pager <IQueryable <UserDepartRoleInfo> >(total, user_dep_role));
        }
        public async Task <BaseResult <UserApplyEntity> > GetById(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(new BaseResult <UserApplyEntity>(808));
            }

            Expression <Func <UserApplyEntity, bool> > where_serch = LinqUtil.True <UserApplyEntity>();

            where_serch = where_serch.AndAlso(c => c.apply_id.Contains(id));

            //调用仓储方法查询分页并且响应给前台
            UserApplyEntity query = (from c in await userApplyRepository.GetAllAsync(where_serch)
                                     join o in await userRepository.GetAllAsync() on c.user_id equals o.user_id
                                     join n in await userRepository.GetAllAsync() on c.detail_id equals n.user_id into joinTemp
                                     from tmp in joinTemp.DefaultIfEmpty()
                                     select new UserApplyEntity()
            {
                //使用申请人用户Id和处理人用户Id返回用户邮箱信息
                user_id = o.user_email,
                createtime = c.createtime,
                detail_id = tmp == null ? "" : tmp.full_name,
                apply_id = c.apply_id,
                apply_reason = c.apply_reason,
                apply_desc = c.apply_desc,
                row_number = c.row_number,
                is_true = c.is_true
            }).FirstOrDefault();

            return(new BaseResult <UserApplyEntity>(200, query));
        }
Beispiel #6
0
        public async Task <BaseResult <List <ShopCommentView> > > GetShopCommentInfo(string shop_id, int type)
        {
            //判断查询参数(组装查询条件)  1表示好评(5)  2表示中评(2,3,4) 3表示差评(1)
            Expression <Func <ShopCommentInfo, bool> > where_search = LinqUtil.True <ShopCommentInfo>();

            where_search = where_search.AndAlso(c => c.shop_id == shop_id);

            if (type != 0)
            {
                switch (type)
                {
                case 3:
                    where_search = where_search.AndAlso(c => c.comment_star == 1);
                    break;

                case 2:
                    where_search = where_search.AndAlso(c => c.comment_star == 2 || c.comment_star == 3 || c.comment_star == 4);
                    break;

                default:
                    where_search = where_search.AndAlso(c => c.comment_star == 5);
                    break;
                }
            }
            IQueryable <ShopCommentInfo> shopCommentInfos = await commentRepository.GetShopCommentInfo(where_search);

            List <ShopCommentView> shopCommentViews = new List <ShopCommentView>();
            ShopCommentView        shopCommentView  = null;

            //查询到结果之后进行处理,如果已经含有相通版本的,则直接累加图片
            foreach (var shopCommentInfo in shopCommentInfos)
            {
                shopCommentView = shopCommentViews.FirstOrDefault(c => c.comment_id.Equals(shopCommentInfo.comment_id));
                if (shopCommentView == null)
                {
                    shopCommentView               = new ShopCommentView();
                    shopCommentView.comment_id    = shopCommentInfo.comment_id;
                    shopCommentView.user_name     = shopCommentInfo.user_name;
                    shopCommentView.user_image    = shopCommentInfo.user_image;
                    shopCommentView.shop_code     = shopCommentInfo.shop_code;
                    shopCommentView.comment_desc  = shopCommentInfo.comment_desc;
                    shopCommentView.comment_reply = shopCommentInfo.comment_reply;
                    shopCommentView.comment_star  = shopCommentInfo.comment_star;
                    shopCommentView.createtime    = shopCommentInfo.createtime;
                    shopCommentView.image_address.Add(shopCommentInfo.comment_address);
                    shopCommentViews.Add(shopCommentView);
                }
                else
                {
                    shopCommentView.image_address.Add(shopCommentInfo.comment_address);
                }
            }
            return(new BaseResult <List <ShopCommentView> >(200, shopCommentViews));
        }
Beispiel #7
0
        public async Task <OrderPay> OrderInfoByShopSkuId(string user_id, string order_id, string shopsku_id)
        {
            //判断查询参数(组装查询条件)
            Expression <Func <OrderPay, bool> > where_search = LinqUtil.True <OrderPay>();

            where_search = where_search.AndAlso(c => c.user_id == user_id).AndAlso(c => c.order_delete == 1).AndAlso(c => c.orderdetail_delete == 1)
                           .AndAlso(c => c.order_id == order_id).AndAlso(c => c.shopsku_id == shopsku_id);

            var data = await orderRepository.OrderListInfo(where_search);

            return(data.FirstOrDefault());
        }
Beispiel #8
0
        public async Task <IQueryable <OrderPay> > getOrderPay(string id, string user_id)
        {
            //判断查询参数(组装查询条件)
            Expression <Func <OrderPay, bool> > where_search = LinqUtil.True <OrderPay>();

            if (!string.IsNullOrEmpty(id))
            {
                where_search = where_search.AndAlso(c => c.order_id == id).AndAlso(c => c.user_id == user_id).AndAlso(c => c.order_delete == 1)
                               .AndAlso(c => c.order_goods == 1).AndAlso(c => c.order_paystatus == 1);
            }
            var data = await orderRepository.GetOrderPay(where_search);

            return(data);
        }
Beispiel #9
0
        public async Task <Pager <IQueryable <CommentShopInfo> > > List(CommentInfo commentInfo)
        {
            //使用linq join关联三张表查询评论信息(Pls_Comment、Pls_User、Pls_Shop)
            Expression <Func <UserEntity, bool> >    user_serach    = LinqUtil.True <UserEntity>();
            Expression <Func <ShopEntity, bool> >    shop_serach    = LinqUtil.True <ShopEntity>();
            Expression <Func <CommentEntity, bool> > comment_serach = LinqUtil.True <CommentEntity>();

            user_serach.AndAlso(c => c.disable == 0);
            shop_serach.AndAlso(c => c.disable == 0);
            if (!string.IsNullOrEmpty(commentInfo.user_email))
            {
                user_serach = user_serach.AndAlso(b => b.user_email.Contains(commentInfo.user_email));
            }
            if (!string.IsNullOrEmpty(commentInfo.shop_name))
            {
                shop_serach = shop_serach.AndAlso(b => b.shop_name.Contains(commentInfo.shop_name));
            }
            if ((commentInfo.status) != -1)
            {
                comment_serach = comment_serach.AndAlso(b => b.disable == commentInfo.status);
            }

            int pageindex = commentInfo.pageindex;      //页码,因为没有set,所以就重新定义一个变量
            //异步读取总数
            int total = await commentRepository.CountAsync(comment_serach);

            //调用仓储方法查询分页并且响应给前台
            IQueryable <CommentShopInfo> query = (from c in await commentRepository.GetAllAsync(comment_serach)
                                                  join d in await userRepository.GetAllAsync(user_serach)
                                                  on c.user_id equals d.user_id
                                                  join e in await shopRepository.GetAllAsync(shop_serach)
                                                  on c.shop_id equals e.shop_id
                                                  orderby c.createtime descending
                                                  select new CommentShopInfo
            {
                comment_id = c.comment_id,
                user_email = d.user_email,
                shop_name = e.shop_name,
                comment_star = c.comment_star,
                comment_desc = c.comment_desc,
                comment_reply = c.comment_reply,
                createtime = c.createtime,
                disable = c.disable,
                disabledesc = null,
                commentImage = null
            }).Skip((--pageindex * commentInfo.pagesize)).Take(commentInfo.pagesize);

            return(new Pager <IQueryable <CommentShopInfo> >(total, query));
        }
Beispiel #10
0
        public async Task <Pager <IQueryable <UserOrderInfo> > > List(OrderInfo orderInfo)
        {
            //判断查询参数(组装查询条件)
            Expression <Func <UserEntity, bool> >  user_search  = LinqUtil.True <UserEntity>();
            Expression <Func <OrderEntity, bool> > order_search = LinqUtil.True <OrderEntity>();

            user_search.AndAlso(c => c.disable == 0);
            if (!string.IsNullOrEmpty(orderInfo.user_email))
            {
                user_search = user_search.AndAlso(c => c.user_email.Contains(orderInfo.user_email));
            }
            if (!string.IsNullOrEmpty(orderInfo.order_number))
            {
                order_search = order_search.AndAlso(c => c.order_number.Contains(orderInfo.order_number));
            }
            if (orderInfo.order_paystatus != -1)
            {
                order_search = order_search.AndAlso(c => c.order_paystatus == orderInfo.order_paystatus);
            }
            if (orderInfo.disable != -1)
            {
                order_search = order_search.AndAlso(c => c.disable == orderInfo.disable);
            }
            int pageindex = orderInfo.pageindex;

            //异步读取总数
            int total = await orderRepository.CountAsync(order_search);

            IQueryable <UserOrderInfo> query = (from o in await orderRepository.GetAllAsync(order_search)
                                                join u in await userRepository.GetAllAsync(user_search) on o.user_id equals u.user_id
                                                orderby o.createtime descending
                                                select new UserOrderInfo()
            {
                order_id = o.order_id,
                order_number = o.order_number,
                order_total = o.order_total,
                order_privilege = o.order_privilege,
                order_actualpay = o.order_actualpay,
                order_paystatus = o.order_paystatus,
                order_payway = o.order_payway,
                order_goods = o.order_goods,
                order_delete = o.order_delete,
                createtime = o.createtime,
                disable = o.disable,
                user_email = u.user_email
            }).Skip((--pageindex * orderInfo.pagesize)).Take(orderInfo.pagesize);

            return(new Pager <IQueryable <UserOrderInfo> >(total, query));
        }
Beispiel #11
0
        public async Task <BaseResult <bool> > checkData(string user_id, string content)
        {
            //这里可以用手机号以及电话号码和邮箱登录,判断是否重复
            Expression <Func <UserEntity, bool> > where = LinqUtil.True <UserEntity>();
            where = RegexUtil.Email(content) ? where.AndAlso(c => c.user_email == content)
                : where.AndAlso(c => c.user_phone == content);

            where = where.AndAlso(c => c.user_id != user_id);

            int count = await userRepository.CountAsync(where);

            if (count > 0)
            {
                return(new BaseResult <bool>(900, true));
            }
            return(new BaseResult <bool>(200, false));
        }
Beispiel #12
0
        public async Task <BaseResult <bool> > LoginFront(string login_name_in, string user_pwd_in)
        {
            if (string.IsNullOrEmpty(login_name_in) || string.IsNullOrEmpty(user_pwd_in))
            {
                return(new BaseResult <bool>(808, false));
            }

            //这里可以用邮箱和手机号登陆,需要判断使用什么方式登录,查询用户信息之后验证是否可以访问
            Expression <Func <UserEntity, bool> > where = LinqUtil.True <UserEntity>();
            where = RegexUtil.Email(login_name_in) ? where.AndAlso(c => c.user_email == login_name_in) :
                    where.AndAlso(c => c.user_phone == login_name_in);
            where = where.AndAlso(c => c.user_pwd == CommonUtil.Md5(user_pwd_in));

            UserEntity userEntity = await userRepository.GetAsync(where);

            if (userEntity == null)
            {
                return(new BaseResult <bool>(1000, false));
            }
            if (userEntity.disable == (int)DisableStatus.disable_true)
            {
                return(new BaseResult <bool>(1004, false));
            }
            if (userEntity.user_activation == (int)DisableStatus.disable_true)
            {
                return(new BaseResult <bool>(1005, false));
            }

            //修改用户当前时间为当前时间
            await userRepository.UpdateAsync(new UserEntity()
            {
                user_id = userEntity.user_id, last_time = DateTime.Now
            }, true, true, c => c.last_time);

            UserSession userSession = new UserSession
            {
                user_id    = userEntity.user_id,
                user_name  = userEntity.user_name + userEntity.user_code,
                user_image = userEntity.user_image
            };

            httpContextUtil.setObjectAsJson(KeyUtil.user_info_front, userSession);
            return(new BaseResult <bool>(200, true));
        }
Beispiel #13
0
        public async Task <Pager <IQueryable <ShopEntity> > > List(ShopInfo shopInfo)
        {
            //判断查询参数(组装查询条件)
            Expression <Func <ShopEntity, bool> > where_search = LinqUtil.True <ShopEntity>();

            if (!string.IsNullOrEmpty(shopInfo.shop_name))
            {
                where_search = where_search.AndAlso(c => c.shop_name.Contains(shopInfo.shop_name));
            }

            if (!string.IsNullOrEmpty(shopInfo.shop_number))
            {
                where_search = where_search.AndAlso(c => c.shop_number.Contains(shopInfo.shop_number));
            }

            if (shopInfo.shop_isdiscount != -1)
            {
                where_search = where_search.AndAlso(c => c.shop_isdiscount == (shopInfo.shop_isdiscount == 0) ? true : false);
            }

            if (shopInfo.disable != -1)
            {
                where_search = where_search.AndAlso(c => c.disable == shopInfo.disable);
            }

            //调用仓储方法查询分页并且处理之后响应前台
            //调用仓储方法查询分页并且响应给前台
            int total = await shopRepository.CountAsync(where_search);

            IQueryable <ShopEntity> shopEntitys = await shopRepository.GetPageAllAsync(shopInfo.pageindex, shopInfo.pagesize, where_search, c => c.createtime, (c => new ShopEntity()
            {
                shop_id = c.shop_id,
                shop_name = c.shop_name,
                shop_memo = c.shop_memo,
                shop_number = c.shop_number,
                shop_defaultimg = c.shop_defaultimg,
                shop_isdiscount = c.shop_isdiscount,
                createtime = c.createtime,
                disable = c.disable
            }), false);

            return(new Pager <IQueryable <ShopEntity> >(total, shopEntitys));
        }
Beispiel #14
0
        public async Task <Pager <IQueryable <MessageShowInfo> > > List(MessageInfo messageInfo)
        {
            //判断查询参数
            Expression <Func <UserEntity, bool> >    userwhere_serach = LinqUtil.True <UserEntity>();
            Expression <Func <MessageEntity, bool> > where_serach     = LinqUtil.True <MessageEntity>();

            if (!string.IsNullOrEmpty(messageInfo.user_email))
            {
                userwhere_serach = userwhere_serach.AndAlso(b => b.user_email.Contains(messageInfo.user_email));
            }
            if ((messageInfo.disable_status) != -1)
            {
                where_serach = where_serach.AndAlso(b => b.disable == messageInfo.disable_status);
            }

            int total = await messageRepository.CountAsync(where_serach);

            int pageindex = messageInfo.pageindex;              //页码,因为没有set,所以就重新定义一个变量

            //调用仓储方法查询分页并且响应给前台
            IQueryable <MessageShowInfo> query = (from c in await messageRepository.GetAllAsync(where_serach)
                                                  join o in await userRepository.GetAllAsync(userwhere_serach) on c.user_id equals o.user_id into temp
                                                  from leftjoin in temp.DefaultIfEmpty()
                                                  select new MessageShowInfo()
            {
                user_email = leftjoin == null ? "" : leftjoin.user_email,                                    //不需要创建实体,世界使用用户Id显示用户邮箱
                user_name = leftjoin == null ? "" : leftjoin.user_name,                                      //不需要创建实体,世界使用用户Id显示用户邮箱
                user_image = leftjoin == null ? "" : leftjoin.user_image,
                createtime = c.createtime,
                disable = c.disable,
                disabledesc = c.disabledesc,
                message_desc = c.message_desc,
                message_id = c.message_id,
                message_read = c.message_read,
                message_solve = c.message_solve,
                message_type = c.message_type,
                row_number = c.row_number
            }).OrderByDescending(c => c.createtime).Skip((--pageindex * messageInfo.pagesize)).Take(messageInfo.pagesize);

            return(new Pager <IQueryable <MessageShowInfo> >(total, query));
        }
        public async Task <Pager <IQueryable <DepartmentEntity> > > List(DepartmentInfo departmentInfo)
        {
            //判断查询参数
            Expression <Func <DepartmentEntity, bool> > where = LinqUtil.True <DepartmentEntity>();
            if (!string.IsNullOrEmpty(departmentInfo.name))
            {
                where = where.AndAlso(c => c.department_name.Contains(departmentInfo.name));
            }
            if (departmentInfo.status != -1)
            {
                where = where.AndAlso(c => c.disable == departmentInfo.status);
            }

            //调用仓储方法查询分页并且响应给前台
            int total = await departmentRepository.CountAsync(where);

            IQueryable <DepartmentEntity> list = await departmentRepository.GetPageAllAsync <DepartmentEntity, DateTime, DepartmentEntity>(
                departmentInfo.pageindex, departmentInfo.pagesize, where, c => c.createtime, null, false);

            return(new Pager <IQueryable <DepartmentEntity> >(total, list.AsQueryable()));
        }
Beispiel #16
0
        public async Task <Pager <IQueryable <NoticeEntity> > > List(NoticeInfo noticeInfo)
        {
            //判断查询参数
            Expression <Func <NoticeEntity, bool> > where = LinqUtil.True <NoticeEntity>();
            if (!string.IsNullOrEmpty(noticeInfo.notice_desc))
            {
                where = where.AndAlso(c => c.notice_desc.Contains(noticeInfo.notice_desc));
            }
            if (noticeInfo.disable != -1)
            {
                where = where.AndAlso(c => c.disable == noticeInfo.disable);
            }

            //调用仓储方法查询分页并且响应给前台
            int total = await noticeRepository.CountAsync(where);

            IQueryable <NoticeEntity> list = await noticeRepository.GetPageAllAsync <NoticeEntity, DateTime, NoticeEntity>(
                noticeInfo.pageindex, noticeInfo.pagesize, where, c => c.createtime, null, false);

            return(new Pager <IQueryable <NoticeEntity> >(total, list.AsQueryable()));
        }
Beispiel #17
0
        public Pager <IQueryable <RoleEntity> > List(RoleInfo roleInfo)
        {
            //判断查询参数(组装查询条件)
            Expression <Func <RoleEntity, bool> > where_search = LinqUtil.True <RoleEntity>();

            if (!string.IsNullOrEmpty(roleInfo.name))
            {
                where_search = where_search.AndAlso(c => c.role_name.Contains(roleInfo.name));
            }
            if (roleInfo.status != -1)
            {
                where_search = where_search.AndAlso(c => c.disable == roleInfo.status);
            }

            //调用仓储方法查询分页并且响应给前台
            int total = 0;
            List <RoleEntity> list = roleRepository.GetPageAllList <RoleEntity, DateTime, RoleEntity>(
                roleInfo.pageindex, roleInfo.pagesize, where_search, c => c.createtime, null, out total, true);

            return(new Pager <IQueryable <RoleEntity> >(total, list.AsQueryable()));
        }
        public async Task <Pager <IQueryable <UserApplyEntity> > > List(UserApplyInfo userApplyInfo)
        {
            //判断查询参数
            Expression <Func <UserApplyEntity, bool> > where_serch      = LinqUtil.True <UserApplyEntity>();
            Expression <Func <UserEntity, bool> >      userwhere_serach = LinqUtil.True <UserEntity>();

            if (userApplyInfo.istrue != -1)
            {
                where_serch = userApplyInfo.istrue == 0 ? where_serch.AndAlso(c => c.is_true == false) : where_serch.AndAlso(c => c.is_true == true);
            }
            if (!string.IsNullOrEmpty(userApplyInfo.user_email))
            {
                userwhere_serach = userwhere_serach.AndAlso(c => c.user_email.Contains(userApplyInfo.user_email));
            }

            int pageindex = userApplyInfo.pageindex;
            int total     = await userApplyRepository.CountAsync(where_serch);

            //调用仓储方法查询分页并且响应给前台

            IQueryable <UserApplyEntity> query = (from c in await userApplyRepository.GetAllAsync(where_serch)
                                                  join o in await userRepository.GetAllAsync(userwhere_serach) on c.user_id equals o.user_id
                                                  join n in await userRepository.GetAllAsync() on c.detail_id equals n.user_id into joinTemp
                                                  from tmp in joinTemp.DefaultIfEmpty()
                                                  select new UserApplyEntity()
            {
                //使用申请人用户Id和处理人用户Id返回用户邮箱信息
                user_id = o.user_email,
                createtime = c.createtime,
                detail_id = tmp == null ? "" : tmp.full_name,
                apply_id = c.apply_id,
                apply_reason = c.apply_reason,
                apply_desc = c.apply_desc,
                row_number = c.row_number,
                is_true = c.is_true
            }).OrderByDescending(c => c.createtime).Skip((--pageindex * userApplyInfo.pagesize)).Take(userApplyInfo.pagesize);

            return(new Pager <IQueryable <UserApplyEntity> >(total, query));
        }
Beispiel #19
0
        public async Task <BaseResult <bool> > Login(string login_name_in, string user_pwd_in)
        {
            if (string.IsNullOrEmpty(login_name_in) || string.IsNullOrEmpty(user_pwd_in))
            {
                return(new BaseResult <bool>(808, false));
            }

            //这里可以用邮箱和手机号登陆,需要判断使用什么方式登录,查询用户信息之后验证是否可以访问
            Expression <Func <UserEntity, bool> > where = LinqUtil.True <UserEntity>();
            where = RegexUtil.Email(login_name_in) ? where.AndAlso(c => c.user_email == login_name_in) :
                    where.AndAlso(c => c.user_phone == login_name_in);
            where = where.AndAlso(c => c.user_pwd == CommonUtil.Md5(user_pwd_in));

            UserEntity userEntity = await userRepository.GetAsync(where);

            if (userEntity == null)
            {
                return(new BaseResult <bool>(1000, false));
            }
            if (userEntity.disable == (int)DisableStatus.disable_true)
            {
                return(new BaseResult <bool>(1004, false));
            }
            if (userEntity.user_activation == (int)DisableStatus.disable_true)
            {
                return(new BaseResult <bool>(1005, false));
            }
            if (userEntity.user_visit == (int)DisableStatus.disable_true)
            {
                return(new BaseResult <bool>(1006, false));
            }

            //用户登录正常,修改用户登录时间并且将登录的信息保存到Session中
            await userRepository.UpdateAsync(new UserEntity()
            {
                user_id = userEntity.user_id, last_time = DateTime.Now
            }, true, true, c => c.last_time);

            //处理信息,如果redis连接成功,则直接判断是否存在值,如果存在,则直接使用,否则直接查询并且保存   ,如果连接失败,则直接查询
            List <string> buttionActions = null;

            if (redisHelp._conn != null)
            {
                string key = string.Format(RedisKeyUtil.login_admin, userEntity.user_id);
                if (redisHelp.KeyExists(key))
                {
                    buttionActions = JsonNetHelper.DeserializeObject <List <string> >(await redisHelp.StringGetAsync(key));
                }
                else
                {
                    buttionActions = buttonActionRepository.GetMenuInfo(userEntity.user_id, c => c.action_type != (int)ActionType.front &&
                                                                        c.action_url != null && c.disable == (int)DisableStatus.disable_false).Select(c => c.action_url).ToList();
                    await redisHelp.StringSetAsync(key, JsonNetHelper.SerializeObject(buttionActions), new TimeSpan(30, 12, 60));
                }
            }
            else
            {
                buttionActions = buttonActionRepository.GetMenuInfo(userEntity.user_id,
                                                                    c => c.action_type != (int)ActionType.front && c.action_url != null && c.disable == (int)DisableStatus.disable_false).Select(c => c.action_url).ToList();
            }

            UserSession userSession = new UserSession
            {
                user_id    = userEntity.user_id,
                user_name  = userEntity.user_name + userEntity.user_code,
                user_image = userEntity.user_image,
                full_name  = userEntity.full_name,
                action_url = buttionActions == null ? null : buttionActions
            };

            httpContextUtil.setObjectAsJson(KeyUtil.user_info, userSession);
            return(new BaseResult <bool>(200, true));
        }