Exemple #1
0
        public object UserRegister(ApiUserRegisterModel register)
        {
            if (register.Type == ApiRegisterFlag.ByPwd) //通过密码
            {
                var isHave = UserBusiness.GetItemByUserAccount(register.UserAccount);
                if (isHave != null)
                {
                    return(ApiReturnModel.ReturnError("当前账号已经注册"));
                }
                var userInfo = ApiToDalModelMapping.UserRegisterModelToUserInfo(register, (int)UserLvModel.User);

                userInfo = UserBusiness.AddItem(userInfo);

                #region 开始写入缓存

                var token = Guid.NewGuid();
                CacheHelper.TryAddCache($"{token}-{AuthenticationPara.UserAuthentication}", userInfo, DateTime.Now.AddDays(30)); //缓存

                ApiUserInfoModel apiUserInfo = new ApiUserInfoModel()
                {
                    Token       = token.ToString(),
                    UserAccount = userInfo.UserAccount,
                    UserLv      = userInfo.UserLv.ToString()
                };

                #endregion

                ApiReturnModel.ReturnOk("注册成功", apiUserInfo);
            }
            else if (register.Type == ApiRegisterFlag.ByValidate) //通过验证码注册
            {
            }

            return(ApiReturnModel.ReturnOk());
        }
Exemple #2
0
        public ApiReturnModel UpdateUserBasicsData(ApiUserInfoModel apiUserInfoModel)
        {
            var userInfo = GetCurrentUserInfo();

            userInfo.CompanyName  = apiUserInfoModel.CompanyName;
            userInfo.UserImg      = apiUserInfoModel.UserImg;
            userInfo.UserPassWord = apiUserInfoModel.UserPwd;

            UserBusiness.UpdateItem(userInfo);

            return(ApiReturnModel.ReturnOk("修改成功"));
        }
Exemple #3
0
        public ApiReturnModel GetUserBasicsData()
        {
            var userInfo = GetCurrentUserInfo();

            userInfo = UserBusiness.GetItemById(userInfo.Id);

            var token = Request.Headers.Authorization.Parameter;

            CacheHelper.TryAddCache($"{token}-{AuthenticationPara.UserAuthentication}", userInfo, DateTime.Now.AddDays(30)); //更新缓存

            ApiUserInfoModel apiUserInfoModel = new ApiUserInfoModel()
            {
                CompanyName = userInfo.CompanyName,
                UserName    = userInfo.UserName,
                UserLv      = UserRoleBusiness.GetItemById(userInfo.UserLv).RoleName
            };

            return(ApiReturnModel.ReturnOk("查询成功", apiUserInfoModel));
        }
Exemple #4
0
        /// <summary>
        /// 业务员登陆
        /// </summary>
        /// <param name="apiLoginUserModel"></param>
        /// <returns></returns>
        public object CountermanLogin([FromBody] ApiLoginUserModel apiLoginUserModel)
        {
            var userInfo = employeeBusiness.GetItemByEmployeePwd(apiLoginUserModel.UserId, apiLoginUserModel.Pwd, (int)UserLvModel.Counterman);

            if (userInfo != null) //密码登陆成功
            {
                var token = Guid.NewGuid();
                CacheHelper.TryAddCache($"{token}-{AuthenticationPara.CountermanAuthentication}", userInfo, DateTime.Now.AddDays(30)); //缓存
                ApiUserInfoModel apiUserInfo = new ApiUserInfoModel()
                {
                    Token    = token.ToString(),
                    UserName = userInfo.EmployeeName,
                    UserLv   = EnumHelper.GetDescriptionByValue <UserLvModel>(userInfo.RoleLv)
                };
                return(ApiReturnModel.ReturnOk("登陆成功", apiUserInfo));
            }

            return(ApiReturnModel.ReturnError("用户名或者密码错误"));
        }