feat 数据权限
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using Dlhis.Entity.Sys.Entities;
|
||||
using Dlhis.Entity.Sys.Enums;
|
||||
using Dlhis.Sys.DataPermission.Request;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
|
||||
namespace Dlhis.Sys.DataPermission.Services.Implements;
|
||||
|
||||
public class DataPermissionService : IDataPermissionService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
|
||||
public DataPermissionService(IDbContext dbContext)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task SaveAsync(DataPermissionSaveRequest request)
|
||||
{
|
||||
var data = await _dbContext.Queryable<DataPermissionEntity>()
|
||||
.Where(x => x.AssignValue == request.AssignValue)
|
||||
.Where(x => x.AssignType == AssignTypeEnumType.User)
|
||||
.Where(x => x.UniqueType == request.UniqueType)
|
||||
.ToListAsync();
|
||||
|
||||
await _dbContext.DeleteReallyAsync(data);
|
||||
|
||||
await _dbContext.InsertAsync(request.Codes.Select(x => new DataPermissionEntity
|
||||
{
|
||||
AssignType = AssignTypeEnumType.User,
|
||||
AssignValue = request.AssignValue,
|
||||
UniqueType = request.UniqueType,
|
||||
UniqueValue = x
|
||||
}).ToList());
|
||||
}
|
||||
|
||||
public async Task<List<Guid>> GetAssignmentsAsync(string assignValue, DeviceAssignmentTypeEnumType uniqueType)
|
||||
{
|
||||
return await _dbContext.Queryable<DataPermissionEntity>()
|
||||
.Where(x => x.AssignValue == assignValue)
|
||||
.Where(x => x.AssignType == AssignTypeEnumType.User)
|
||||
.Where(x => x.UniqueType == uniqueType)
|
||||
.Select(x => x.UniqueValue)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user