forked from ddrilling/AsbCloudServer
#7205798 fix
This commit is contained in:
parent
408429a0b5
commit
5ca55dfc0a
@ -5,7 +5,6 @@ using AsbCloudDb;
|
|||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.EfCache;
|
using AsbCloudInfrastructure.EfCache;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -48,7 +47,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
|
|
||||||
await dbContext.SaveChangesAsync(token);
|
await dbContext.SaveChangesAsync(token);
|
||||||
DropCacheUsers();
|
DropCacheUsers();
|
||||||
return updatedEntity?.Entity?.Id ?? 0;
|
return updatedEntity.Entity.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<int> InsertRangeAsync(IEnumerable<UserExtendedDto> newItems, CancellationToken token = default)
|
public Task<int> InsertRangeAsync(IEnumerable<UserExtendedDto> newItems, CancellationToken token = default)
|
||||||
@ -109,7 +108,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
var result = dbContext.Users.Upsert(entity);
|
var result = dbContext.Users.Upsert(entity);
|
||||||
await dbContext.SaveChangesAsync(token);
|
await dbContext.SaveChangesAsync(token);
|
||||||
DropCacheUsers();
|
DropCacheUsers();
|
||||||
return result?.Entity?.Id ?? 0;
|
return result.Entity.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> DeleteAsync(int id, CancellationToken token = default)
|
public async Task<int> DeleteAsync(int id, CancellationToken token = default)
|
||||||
@ -122,21 +121,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
var result = dbContext.Users.Remove(entity);
|
var result = dbContext.Users.Remove(entity);
|
||||||
await dbContext.SaveChangesAsync(token);
|
await dbContext.SaveChangesAsync(token);
|
||||||
DropCacheUsers();
|
DropCacheUsers();
|
||||||
return result?.Entity?.Id ?? 0;
|
return result.Entity.Id;
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<int> DeleteAsync(IEnumerable<int> ids, CancellationToken token = default)
|
|
||||||
{
|
|
||||||
var dto = (await GetCacheUserAsync(token)).Where(r => ids.Contains(r.Id));
|
|
||||||
if (dto is null)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
var count = dto.Count();
|
|
||||||
var entities = dto.Select(Convert);
|
|
||||||
dbContext.Users.RemoveRange(entities);
|
|
||||||
await dbContext.SaveChangesAsync(token);
|
|
||||||
DropCacheUsers();
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<UserRoleDto> GetRolesByIdUser(int idUser, int nestedLevel = 0)
|
public IEnumerable<UserRoleDto> GetRolesByIdUser(int idUser, int nestedLevel = 0)
|
||||||
|
@ -40,7 +40,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
|
|
||||||
await dbContext.SaveChangesAsync(token);
|
await dbContext.SaveChangesAsync(token);
|
||||||
DropCacheUserRole();
|
DropCacheUserRole();
|
||||||
return updatedEntity?.Entity?.Id ?? 0;
|
return updatedEntity.Entity.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<int> InsertRangeAsync(IEnumerable<UserRoleDto> newItems, CancellationToken token)
|
public Task<int> InsertRangeAsync(IEnumerable<UserRoleDto> newItems, CancellationToken token)
|
||||||
@ -53,9 +53,6 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
var entities = await GetCacheUserRoleAsync(token)
|
var entities = await GetCacheUserRoleAsync(token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (entities is null)
|
|
||||||
return Enumerable.Empty<UserRoleDto>();
|
|
||||||
|
|
||||||
return entities.Select(Convert);
|
return entities.Select(Convert);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -100,7 +97,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
var result = dbContext.UserRoles.Upsert(entity);
|
var result = dbContext.UserRoles.Upsert(entity);
|
||||||
await dbContext.SaveChangesAsync(token);
|
await dbContext.SaveChangesAsync(token);
|
||||||
DropCacheUserRole();
|
DropCacheUserRole();
|
||||||
return result?.Entity?.Id ?? 0;
|
return result.Entity.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<UserRoleDto> GetNestedById(int id, int recursionLevel = 7)
|
public IEnumerable<UserRoleDto> GetNestedById(int id, int recursionLevel = 7)
|
||||||
@ -135,22 +132,7 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
var removeEntity = dbContext.UserRoles.Remove(entity);
|
var removeEntity = dbContext.UserRoles.Remove(entity);
|
||||||
await dbContext.SaveChangesAsync(token);
|
await dbContext.SaveChangesAsync(token);
|
||||||
DropCacheUserRole();
|
DropCacheUserRole();
|
||||||
return removeEntity?.Entity?.Id ?? 0;
|
return removeEntity.Entity.Id;
|
||||||
}
|
|
||||||
else return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<int> DeleteAsync(IEnumerable<int> ids, CancellationToken token)
|
|
||||||
{
|
|
||||||
var entities = (await GetCacheUserRoleAsync(token)).Where(r => ids.Contains(r.Id));
|
|
||||||
|
|
||||||
if (entities is not null)
|
|
||||||
{
|
|
||||||
var count = entities.Count();
|
|
||||||
dbContext.UserRoles.RemoveRange(entities);
|
|
||||||
await dbContext.SaveChangesAsync(token);
|
|
||||||
DropCacheUserRole();
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user