生产BUG修改
This commit is contained in:
@@ -16,7 +16,7 @@ namespace 全自动水压检测仪.DATA
|
||||
|
||||
public UserRepository()
|
||||
{
|
||||
_connectionString = "Server=localhost;Database=fullautowaterpressure;User=root;Password=123456;port=3306;charset=utf8;";
|
||||
_connectionString = DatabaseConnectionManager.ConnectionString;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -26,7 +26,7 @@ namespace 全自动水压检测仪.DATA
|
||||
/// <returns>用户对象,不存在返回null</returns>
|
||||
public User GetUserByUsername(string username)
|
||||
{
|
||||
using (var connection = new MySqlConnection(_connectionString))
|
||||
using (var connection = DatabaseConnectionManager.CreateConnection())
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace 全自动水压检测仪.DATA
|
||||
/// <returns>用户对象,不存在返回null</returns>
|
||||
public User GetUserById(int userId)
|
||||
{
|
||||
using (var connection = new MySqlConnection(_connectionString))
|
||||
using (var connection = DatabaseConnectionManager.CreateConnection())
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace 全自动水压检测仪.DATA
|
||||
/// <returns>是否创建成功</returns>
|
||||
public bool CreateUser(User user, string plainPassword)
|
||||
{
|
||||
using (var connection = new MySqlConnection(_connectionString))
|
||||
using (var connection = DatabaseConnectionManager.CreateConnection())
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace 全自动水压检测仪.DATA
|
||||
/// <returns>是否更新成功</returns>
|
||||
public bool UpdateUser(User user)
|
||||
{
|
||||
using (var connection = new MySqlConnection(_connectionString))
|
||||
using (var connection = DatabaseConnectionManager.CreateConnection())
|
||||
{
|
||||
connection.Open();
|
||||
string sql = @"UPDATE sys_users
|
||||
@@ -160,7 +160,7 @@ namespace 全自动水压检测仪.DATA
|
||||
/// <returns>是否删除成功</returns>
|
||||
public bool DeleteUser(int userId)
|
||||
{
|
||||
using (var connection = new MySqlConnection(_connectionString))
|
||||
using (var connection = DatabaseConnectionManager.CreateConnection())
|
||||
{
|
||||
connection.Open();
|
||||
string sql = @"DELETE FROM sys_users WHERE id = @id";
|
||||
@@ -175,7 +175,7 @@ namespace 全自动水压检测仪.DATA
|
||||
/// <returns>用户列表</returns>
|
||||
public List<User> GetAllUsers()
|
||||
{
|
||||
using (var connection = new MySqlConnection(_connectionString))
|
||||
using (var connection = DatabaseConnectionManager.CreateConnection())
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace 全自动水压检测仪.DATA
|
||||
/// <returns>是否修改成功</returns>
|
||||
public bool ChangePassword(int userId, string oldPassword, string newPassword)
|
||||
{
|
||||
using (var connection = new MySqlConnection(_connectionString))
|
||||
using (var connection = DatabaseConnectionManager.CreateConnection())
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace 全自动水压检测仪.DATA
|
||||
/// <returns>是否重置成功</returns>
|
||||
public bool ResetPassword(int userId, string newPassword)
|
||||
{
|
||||
using (var connection = new MySqlConnection(_connectionString))
|
||||
using (var connection = DatabaseConnectionManager.CreateConnection())
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace 全自动水压检测仪.DATA
|
||||
/// <returns>是否更新成功</returns>
|
||||
public bool UpdateLastLoginTime(string username)
|
||||
{
|
||||
using (var connection = new MySqlConnection(_connectionString))
|
||||
using (var connection = DatabaseConnectionManager.CreateConnection())
|
||||
{
|
||||
connection.Open();
|
||||
string sql = @"UPDATE sys_users
|
||||
|
||||
Reference in New Issue
Block a user