Пример #1
0
        public async Task <List <AppUserMenuResDto> > GetAppUserMenus(int userId, string menuCode)
        {
            var mainMenuTask = _menuClient.FindByEntity(new Dictionary <string, string> {
                { "MENU_TYPE", "M" },
                { "TERMINAL_TYPE", "APP" },
                { "MENU_CODE", menuCode },
            });
            var userTask = _userClient.FindById(new ComEntity.IdModel {
                ID = userId
            });

            await mainMenuTask;
            await userTask;

            //查询主菜单下的所有子菜单
            var subMenuList = _menuClient.FindAllByEntity(new Dictionary <string, string> {
                { "MAIN_MENU_ID", mainMenuTask.Result.ID.ToString() }
            }).Result;

            if (userTask.Result.IS_MAIN != "Y")
            {
                //查询指定用户有权限的菜单
                var userMenuTask = _userMenuClient.FindMenuByUser(new ComEntity.IdModel {
                    ID = userId
                }).Result;
                var userMenuSubMenuIds = userMenuTask.Select(um => um.SUBMENU_ID);
                subMenuList = subMenuList.Where(mu => userMenuSubMenuIds.Contains(mu.ID)).ToList();
            }

            return(EntityAutoMapper.ConvertMappingList <AppUserMenuResDto, B2B_MENU>(subMenuList.OrderBy(m => m.ORDER).ToList()));
        }
Пример #2
0
        /// <summary>
        /// 获取用户扩展类
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public async Task <B2B_USER_Extend> FindExtendById(int userId)
        {
            //获取用户记录
            var user = await _userClient.FindById(new IdModel { ID = userId });

            //扩展类转换
            var userExtend = EntityAutoMapper.ConvertMapping <B2B_USER_Extend, B2B_USER>(user);
            //获取微信详情
            var wxFindDic = new Dictionary <string, string>();

            wxFindDic.Add("USER_ID", user.ID.ToString());
            return(userExtend);
        }
Пример #3
0
        public override JsonResult FindById(int ID)
        {
            B2B_USER dbModel = userClient.FindById(new IdModel {
                ID = ID
            }).Result;

            return(Json(dbModel));
        }
Пример #4
0
        /// <summary>
        /// 0成功 1用户不存在 2密码错误 3 验证码错误 4账号已冻结
        /// </summary>
        /// <param name="context"></param>
        /// <param name="name"></param>
        /// <param name="pwd"></param>
        /// <param name="verify"></param>
        /// <returns></returns>
        public static LoginResultEntity UserLogin(this HttpContext context, IUserClient userClient, IUserFunctionClient userFunctionClient, Func <CurrentUserEntity, string> tokenBuildFunc, string name = "", string pwd = "", string verify = "", LoginSource loginSource = LoginSource.Client, int userId = 0)
        {
            //验证码
            //var LoginValidateCode = context.Session.GetString("LoginValidateCode");
            //context.Session.Remove("LoginValidateCode");
            //if (string.IsNullOrEmpty(verify) || LoginValidateCode == null || !LoginValidateCode.Equals(verify, StringComparison.OrdinalIgnoreCase))
            //{
            //    return LoginResult.WrongVerify;
            //}

            CurrentUserEntity currentUser;

            if (userId != 0)
            {
                var findUser = userClient.FindById(new B2b.ComEntity.IdModel {
                    ID = userId
                }).Result;
                currentUser = new CurrentUserEntity()
                {
                    END_DATE      = findUser.END_DATE,
                    ID            = findUser.ID,
                    IS_MAIN       = findUser.IS_MAIN,
                    IS_WXIN_LOGIN = findUser.IS_WXIN_LOGIN,
                    MAIL          = findUser.MAIL,
                    MOBILE        = findUser.MOBILE,
                    PARTY_ID      = Convert.ToInt32(findUser.PARTY_ID),
                    PARTY_TYPE    = findUser.PARTY_TYPE,
                    REG_STATUS    = findUser.REG_STATUS,
                    START_DATE    = findUser.START_DATE,
                    USER          = findUser.USER,
                    USER_NAME     = findUser.USER_NAME
                };
            }
            else
            {
                if (loginSource == LoginSource.Client)
                {
                    currentUser = userClient.UserLogin(new LoginEntity {
                        USER = name, PASSWORD = pwd
                    }).Result;
                }
                else
                {
                    currentUser = userClient.ManagerUserLogin(new LoginEntity {
                        USER = name, PASSWORD = pwd
                    }).Result;
                }
            }
            if (currentUser == null || currentUser.ID == 0)
            {
                return(new LoginResultEntity(LoginResult.WrongLogin));
            }
            else
            {
                if (currentUser.REG_STATUS == "0")
                {
                    return(new LoginResultEntity(LoginResult.WaitAudit));
                }
                //用户有效性判断 (且"当前日期"在“生效日期START_DATE”与“失效日期END_DATE”之间)
                else if (currentUser.REG_STATUS == "2" || currentUser.START_DATE == null || DateTime.Now < currentUser.START_DATE || (currentUser.END_DATE != null && DateTime.Now >= currentUser.END_DATE))
                {
                    return(new LoginResultEntity(LoginResult.Closed));
                }

                var userFunctions = userFunctionClient.FindAllByEntity(new Dictionary <string, string> {
                    { "USER_ID", currentUser.ID.ToString() }
                }).Result;
                for (int i = 0; i < userFunctions.Count; i++)
                {
                    currentUser.UserFunctionEnabledList.Add(userFunctions[i].MENU_FUNCTION_CODE);
                }


                string token = tokenBuildFunc(currentUser);
                //context.Session.SetString("CurrentUser", JsonHelper.ToJson<CurrentUserEntity>(currentUser));
                logger.Debug(string.Format("用户id={0} Name={1}登录系统", currentUser.ID, currentUser.USER));

                userClient.LastLoginTimeReload(new ECP.B2b.ComEntity.IdModel {
                    ID = currentUser.ID
                });

                return(new LoginResultEntity(LoginResult.Success, token)
                {
                    userId = currentUser.ID
                });
            }
        }