/// <summary>
        /// 注册账户
        /// </summary>
        /// <param name="registerDto">账户相关信息</param>
        /// <returns></returns>
        public bool RegisterAccount(RegisterDto registerDto)
        {
            UserInfo userInfo = new UserInfo()
            {
                Id = new CombineIdHelper().CreateId()
            };

            registerDto.ValueMapping(userInfo);
            userInfo.Password = MD5encryption.UserMd5($"happy_{userInfo.Password}");// 密码加密

            return(base.Add(userInfo));
        }
Exemplo n.º 2
0
 /// <summary>
 /// 获取加密字符串
 /// </summary>
 /// <param name="pwd"></param>
 /// <returns></returns>
 public string GetMD5(string pwd)
 {
     return(MD5encryption.GetMD5(pwd));
 }
        /// <summary>
        /// 修改账户密码
        /// </summary>
        /// <param name="accountPasswordUpdateDto">账户id与新密码</param>
        /// <returns></returns>
        public bool UpdateAccountPassword(AccountPasswordUpdateDto accountPasswordUpdateDto)
        {
            bool result = false;

            base.dbConnection.Open();
            IDbTransaction transaction = base.dbConnection.BeginTransaction();

            try
            {
                result = base.dbConnection.Execute(
                    $"UPDATE [{nameof(UserInfo).ToPlural()}] SET [{nameof(UserInfo.Password)}] = '{MD5encryption.UserMd5($"happy_{accountPasswordUpdateDto.Password}")}' WHERE [{nameof(UserInfo.Id)}] = '{accountPasswordUpdateDto.Id}'",
                    null,
                    transaction
                    ) > 0;
                transaction.Commit();
            }
            catch (Exception e)
            {
                transaction.Rollback();
                throw e;
            }
            finally { base.dbConnection.Close(); }
            return(result);
        }
 /// <summary>
 /// 检测密码是为吻合
 /// </summary>
 /// <param name="accountPasswordDto">用户密码和id信息</param>
 /// <returns></returns>
 public bool CompareAccountPassword(AccountPasswordDto accountPasswordDto)
 => base.dbConnection.QueryFirstOrDefault <int>($"SELECT COUNT(*) FROM [{nameof(UserInfo).ToPlural()}] WHERE [{nameof(UserInfo.Id)}] = '{accountPasswordDto.Id}' AND [{nameof(UserInfo.Password)}] = '{MD5encryption.UserMd5($"happy_{accountPasswordDto.Password}")}'") > 0;
 /// <summary>
 /// 检测账户是否存在
 /// </summary>
 /// <param name="loginDto">账户相关信息</param>
 /// <returns></returns>
 public bool CheckAccountExsit(LoginDto loginDto)
 => base.dbConnection.QueryFirstOrDefault <int>($"SELECT COUNT(*) FROM [{nameof(UserInfo).ToPlural()}] WHERE [{nameof(UserInfo.EMail)}] = '{loginDto.EMail}' AND [{nameof(UserInfo.Password)}] = '{MD5encryption.UserMd5($"happy_{loginDto.Password}")}'") > 0;