Ejemplo n.º 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());
        }
        public object AddCounterman([FromBody] ApiCountermanManagerModel apiCountermanManagerModel)
        {
            UserInfo userInfo = new UserInfo()
            {
                Id           = Guid.NewGuid(),
                CreateTime   = DateTime.Now,
                UserLv       = (int)UserLvModel.Counterman,
                UserAccount  = apiCountermanManagerModel.UserAccount,
                UserPassWord = apiCountermanManagerModel.UserPassWord,
                UserName     = apiCountermanManagerModel.UserName
            };

            userBusiness.AddItem(userInfo);
            return(ApiReturnModel.ReturnOk());
        }