/// <summary> /// 重置密码 /// </summary> /// <param name="account"></param> /// <param name="securityCode"></param> /// <param name="type"></param> /// <returns></returns> public Result ResetPassword(string account, string securityCode, int type) { Result result = new Result() { Status = true, Message = "重置密码成功", StatusCode = "RP001" }; try { //加密 string code = MD5Engine.ToMD5String(securityCode); result.Status = DBConnectionManager.Instance.Writer.Update(new AccountResetPassSpefication(account, code, 0).Satifasy()); DBConnectionManager.Instance.Writer.Commit(); if (!result.Status) { result.Message = "重置密码失败"; } } catch (Exception ex) { result.Status = false; result.Message = "修改密码出错" + ex.Message; result.StatusCode = "EX000"; LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:ResetPassword() .AccountService"), LogType.ErrorLog); } return(result); }
/// <summary> /// 注册账户信息 /// </summary> /// <param name="account"></param> /// <returns></returns> public Result <Account> RegistInfo(RegistRequest request) { Result <Account> result = new Result <Account>() { Status = true, Message = "注册账户成功", Data = null, StatusCode = "RR000" }; AccountInfo account = new AccountInfo(); account.Phone = Int64.Parse(request.Phone); account.Email = request.Email; account.SecurityCode = MD5Engine.ToMD5String(request.SecurityCode); account.CreatDate = DateTime.Now; account.BirthdayDate = DateTime.Parse("2000-01-01"); account.Avator = ConstInfo.DefaultHeadBase64; account.BackCorver = ConstInfo.DefaultBackCover; account.Sex = Model.Enum.AccountSex.Male.GetHashCode(); account.RequiredStatus = Model.Enum.AccountRequiredStatus.UnRequired.GetHashCode(); account.Description = ""; account.NickName = request.Phone; //加入数据库 try { IAccountInfoCache service = ServiceObjectContainer.Get <IAccountInfoCache>(); if (service.SearchInfoByKey(account.GetKeyName()) == null) { //入库 result.Status = DBConnectionManager.Instance.Writer.Insert(new AccountAddSpefication(account).Satifasy()); if (result.Status) { DBConnectionManager.Instance.Writer.Commit(); //加入缓存 service.SaveInfo(account); result.Data = account.Copy <Account>(); } } else { result.Status = false; result.Message = "当前账户已存在"; result.StatusCode = "RR001"; } } catch (Exception ex) { DBConnectionManager.Instance.Writer.Rollback(); result.Status = false; result.Message = ex.Message; result.StatusCode = "EX000"; LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:RegistInfo() .AccountService"), LogType.ErrorLog); } return(result); }
/// <summary> /// 登陆 /// </summary> /// <param name="signInCode"></param> /// <param name="securityCode"></param> /// <returns></returns> public Result <Account> SignIn(string signInCode, string securityCode) { Result <Account> result = new Result <Account>() { Status = false }; try { //1.检查是否已经登录 IOnlineAccountCache service = ServiceObjectContainer.Get <IOnlineAccountCache>(); IAccountInfoCache accountservice = ServiceObjectContainer.Get <IAccountInfoCache>(); string phonekey = string.Format("OnlineAI_{0}_*", signInCode); string emailkey = string.Format("OnlineAI_*_{0}", signInCode); string securityCodeMD5 = MD5Engine.ToMD5String(securityCode); OnlineAccountInfo onlineinfo = null; onlineinfo = service.SearchInfoByKey(phonekey); if (onlineinfo == null) { onlineinfo = service.SearchInfoByKey(emailkey); } if (onlineinfo == null) { //2.直接从数据库拿数据 IList <AccountInfo> inforesult = DBConnectionManager.Instance.Reader.Select <AccountInfo>(new AccountSelectSpefication(3, signInCode, securityCodeMD5).Satifasy()); if (inforesult != null && inforesult.Count > 0) { result.Status = true; result.Data = inforesult[0].Copy <Account>(); //保存到缓存 service.SaveInfo(inforesult[0].Copy <OnlineAccountInfo>()); accountservice.SaveInfo(inforesult[0]); } else { result.Message = "用户名或密码错误"; result.StatusCode = "LG000"; } } else { //校验密码 if (onlineinfo.SecurityCode != securityCodeMD5) { result.Message = "密码错误"; result.StatusCode = "LG000"; result.Data = null; } else { //返回结果 result.Status = true; result.Data = onlineinfo.Copy <Account>(); } } } catch (Exception ex) { result.Status = false; result.Data = null; result.Message = ex.Message; result.StatusCode = "EX000"; LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:SignIn() .AccountService"), LogType.ErrorLog); } return(result); }