|
@@ -74,7 +74,7 @@ namespace GxPress.Repository.Implement
|
|
|
/// <returns></returns>
|
|
|
public async Task<IEnumerable<User>> UserListInsAsync(List<int> ids)
|
|
|
{
|
|
|
- return await _repository.GetAllAsync(Q.WhereIn(nameof(User.Id), ids));
|
|
|
+ return await _repository.GetAllAsync(Q.WhereIn(nameof(User.Id), ids).Where(nameof(User.IsDelete), false));
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -84,7 +84,7 @@ namespace GxPress.Repository.Implement
|
|
|
/// <returns></returns>
|
|
|
public async Task<IEnumerable<UserInfoResult>> UserByNameAsync(string name)
|
|
|
{
|
|
|
- var result = await _repository.GetAllAsync(Q.WhereLike(nameof(User.Name), $"%{name}%"));
|
|
|
+ var result = await _repository.GetAllAsync(Q.WhereLike(nameof(User.Name), $"%{name}%").Where(nameof(User.IsDelete), false));
|
|
|
foreach (var item in result)
|
|
|
item.AvatarUrl = StringUtils.AddDomainMin(item.AvatarUrl);
|
|
|
return result.Select(n => _mapper.Map<UserInfoResult>(n));
|
|
@@ -146,7 +146,7 @@ namespace GxPress.Repository.Implement
|
|
|
|
|
|
public async Task<User> GetByPhoneAsync(string phone)
|
|
|
{
|
|
|
- return await _repository.GetAsync(Q.Where(nameof(User.Phone), phone));
|
|
|
+ return await _repository.GetAsync(Q.Where(nameof(User.Phone), phone).Where(nameof(User.IsDelete), false));
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// openId微信认证
|
|
@@ -155,7 +155,7 @@ namespace GxPress.Repository.Implement
|
|
|
/// /// <returns></returns>
|
|
|
public async Task<User> GetByOpenIdAsync(string openId)
|
|
|
{
|
|
|
- return await _repository.GetAsync(Q.Where(nameof(User.OpenId), openId));
|
|
|
+ return await _repository.GetAsync(Q.Where(nameof(User.OpenId), openId).Where(nameof(User.IsDelete), false));
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 绑定微信
|
|
@@ -178,7 +178,7 @@ namespace GxPress.Repository.Implement
|
|
|
}
|
|
|
public async Task<bool> DeleteUsersAsync(IEnumerable<int> userIds)
|
|
|
{
|
|
|
- return await _repository.DeleteAsync(Q.WhereIn(nameof(User.Id), userIds)) > 0;
|
|
|
+ return await _repository.UpdateAsync(Q.WhereIn(nameof(User.Id), userIds).Set(nameof(User.IsDelete), true)) > 0;
|
|
|
}
|
|
|
|
|
|
public async Task<bool> ChangeRoleAsync(IEnumerable<int> userIds, int roleId)
|
|
@@ -224,7 +224,7 @@ namespace GxPress.Repository.Implement
|
|
|
.OrWhereLike(nameof(User.Phone), keyword)
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
+ query.Where(nameof(User.IsDelete), false);
|
|
|
return await _repository.CountAsync(query);
|
|
|
}
|
|
|
|
|
@@ -260,7 +260,7 @@ namespace GxPress.Repository.Implement
|
|
|
.OrWhereLike(nameof(User.Phone), keyword)
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
+ query.Where(nameof(User.IsDelete), false);
|
|
|
return await _repository.GetAllAsync(query);
|
|
|
}
|
|
|
|
|
@@ -285,7 +285,7 @@ namespace GxPress.Repository.Implement
|
|
|
.OrWhereLike(nameof(User.Phone), keyword)
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
+ query.Where(nameof(User.IsDelete), false);
|
|
|
return await _repository.GetAllAsync(query);
|
|
|
}
|
|
|
|
|
@@ -383,7 +383,8 @@ namespace GxPress.Repository.Implement
|
|
|
{
|
|
|
var user = await GetAsync(id);
|
|
|
if (user == null) throw new BusinessException("该用户不存在");
|
|
|
- return await DeleteAsync(id);
|
|
|
+ user.IsDelete = true;
|
|
|
+ return await UpdateAsync(user);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -478,7 +479,7 @@ namespace GxPress.Repository.Implement
|
|
|
{
|
|
|
foreach (var item in request)
|
|
|
{
|
|
|
- var user = await _repository.GetAsync(Q.Where(nameof(User.Phone), item.Phone));
|
|
|
+ var user = await _repository.GetAsync(Q.Where(nameof(User.Phone), item.Phone).Where(nameof(User.IsDelete), false));
|
|
|
if (user != null)
|
|
|
{
|
|
|
continue;
|
|
@@ -650,7 +651,7 @@ namespace GxPress.Repository.Implement
|
|
|
/// <returns></returns>
|
|
|
public async Task<IEnumerable<User>> GetUserByDepartmentIdAsync(int departmentId)
|
|
|
{
|
|
|
- return await _repository.GetAllAsync(Q.Where(nameof(User.DepartmentId), departmentId));
|
|
|
+ return await _repository.GetAllAsync(Q.Where(nameof(User.DepartmentId), departmentId).Where(nameof(User.IsDelete), false));
|
|
|
}
|
|
|
|
|
|
public async Task<IEnumerable<int>> GetUserIdListByDepartmentIdAsync(int departmentId)
|
|
@@ -665,7 +666,7 @@ namespace GxPress.Repository.Implement
|
|
|
{
|
|
|
return await _repository.GetAllAsync<int>(Q
|
|
|
.Select(nameof(User.Id))
|
|
|
- .Where(nameof(User.RoleId), roleId)
|
|
|
+ .Where(nameof(User.RoleId), roleId).Where(nameof(User.IsDelete), false)
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -743,6 +744,7 @@ namespace GxPress.Repository.Implement
|
|
|
departmentValue += ")";
|
|
|
sql = $"select * from ccpph.tede_user where DepartmentId in {departmentValue} and (Name like '%{request.Key}%' or Phone like '%{request.Key}%' or Email like '%{request.Key}%') {notInUserIds}";
|
|
|
}
|
|
|
+ sql += " and IsDelete=0";
|
|
|
var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
|
|
|
var database = new Database(databaseType, _connectionString);
|
|
|
var connection = database.GetConnection();
|
|
@@ -796,6 +798,7 @@ namespace GxPress.Repository.Implement
|
|
|
/// <returns></returns>
|
|
|
public async Task<IEnumerable<User>> FindAllUserAsync(SqlKata.Query query)
|
|
|
{
|
|
|
+ query.Where(nameof(User.IsDelete), false);
|
|
|
return await _repository.GetAllAsync(query);
|
|
|
}
|
|
|
|
|
@@ -806,14 +809,14 @@ namespace GxPress.Repository.Implement
|
|
|
/// <returns></returns>
|
|
|
public async Task<UserDetail> GetGuidAsync(string guid)
|
|
|
{
|
|
|
- var user = await _repository.GetAsync(Q.Where(nameof(User.Guid), guid));
|
|
|
+ var user = await _repository.GetAsync(Q.Where(nameof(User.Guid), guid).Where(nameof(User.IsDelete), false));
|
|
|
user.AvatarUrl = StringUtils.AddDomainMin(user.AvatarUrl);
|
|
|
user.QRCoder = StringUtils.AddDomain(user.QRCoder);
|
|
|
return _mapper.Map<UserDetail>(user);
|
|
|
}
|
|
|
public async Task<IEnumerable<Entity.User>> GetAllUserIm()
|
|
|
{
|
|
|
- string sql = "SELECT * FROM ccpph.tede_user where ImId is null or ImId=''";
|
|
|
+ string sql = "SELECT * FROM ccpph.tede_user where ImId is null or ImId='' and IsDelete=0";
|
|
|
var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
|
|
|
var database = new Database(databaseType, _connectionString);
|
|
|
var connection = database.GetConnection();
|
|
@@ -821,11 +824,13 @@ namespace GxPress.Repository.Implement
|
|
|
}
|
|
|
public async Task<int> CountAsync(Query query)
|
|
|
{
|
|
|
+ query.Where(nameof(User.IsDelete), false);
|
|
|
return await _repository.CountAsync(query);
|
|
|
}
|
|
|
|
|
|
public async Task<IEnumerable<User>> GetAllAsync(Query query)
|
|
|
{
|
|
|
+ query.Where(nameof(User.IsDelete), false);
|
|
|
return await _repository.GetAllAsync(query);
|
|
|
}
|
|
|
/// <summary>
|
|
@@ -835,7 +840,7 @@ namespace GxPress.Repository.Implement
|
|
|
/// <returns></returns>
|
|
|
public async Task<IEnumerable<string>> GetUserIdsAsync(List<int> userIds)
|
|
|
{
|
|
|
- return await _repository.GetAllAsync<string>(Q.Select(nameof(User.Phone)).WhereIn(nameof(User.Id), userIds));
|
|
|
+ return await _repository.GetAllAsync<string>(Q.Select(nameof(User.Phone)).WhereIn(nameof(User.Id), userIds).Where(nameof(User.IsDelete), false));
|
|
|
}
|
|
|
|
|
|
public Task<IEnumerable<User>> FindAllUserAsync()
|
|
@@ -882,7 +887,7 @@ namespace GxPress.Repository.Implement
|
|
|
strSql = strSql.Remove(strSql.Length - 1, 1);
|
|
|
strSql += ")";
|
|
|
}
|
|
|
- string sql = $" select * from ccpph.tede_user where Id in( SELECT UserId FROM ccpph.tede_flow_todo where FlowId={flowId} and Type='{type}' {strSql})";
|
|
|
+ string sql = $" select * from ccpph.tede_user where Id in( SELECT UserId FROM ccpph.tede_flow_todo where FlowId={flowId} and Type='{type}' {strSql}) and IsDelete=0";
|
|
|
var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
|
|
|
var database = new Database(databaseType, _connectionString);
|
|
|
var connection = database.GetConnection();
|
|
@@ -894,7 +899,7 @@ namespace GxPress.Repository.Implement
|
|
|
|
|
|
public async Task<List<JobUserResult>> ElasticSearchUser()
|
|
|
{
|
|
|
- var sql = "select * from ccpph.tede_user where IsUpload=0 limit 0,100";
|
|
|
+ var sql = "select * from ccpph.tede_user where IsUpload=0 and IsDelete=0 limit 0,100";
|
|
|
var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
|
|
|
var database = new Database(databaseType, _connectionString);
|
|
|
var connection = database.GetConnection();
|