fix 返回具体新增和删除数据
This commit is contained in:
@@ -70,9 +70,9 @@ public class DeviceGroupsController : ControllerBase
|
||||
[HttpPost("assign")]
|
||||
[Transactional]
|
||||
[CrossTenant]
|
||||
public async Task AssignDevicesAsync(DeviceAssignRequest request)
|
||||
public async Task<DevicePermissionAssignResponse> AssignDevicesAsync(DeviceAssignRequest request)
|
||||
{
|
||||
await _deviceGroupService.AssignDevicesAsync(request);
|
||||
return await _deviceGroupService.AssignDevicesAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -12,7 +12,7 @@ public interface IDeviceGroupService : IScopeDependency
|
||||
|
||||
Task<List<DeviceUnderGroupResponse>> GetDevicesByGroupCodeAsync(Guid code);
|
||||
|
||||
Task AssignDevicesAsync(DeviceAssignRequest requests);
|
||||
Task<DevicePermissionAssignResponse> AssignDevicesAsync(DeviceAssignRequest requests);
|
||||
|
||||
Task<List<DeviceGroupResponse>> GetAppointmentGroupsAsync();
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
}
|
||||
|
||||
|
||||
public async Task AssignDevicesAsync(DeviceAssignRequest request)
|
||||
public async Task<DevicePermissionAssignResponse> AssignDevicesAsync(DeviceAssignRequest request)
|
||||
{
|
||||
var group = await _dbContext.Queryable<DeviceGroupEntity>().Where(x => x.Code == request.GroupCode).SingleAsync();
|
||||
group.ThrowIfNull("设备分组不存在,无法进行分配");
|
||||
@@ -118,10 +118,10 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
|
||||
await _dbContext.InsertAsync(entities);
|
||||
|
||||
await PermissionResetAsync(request.GroupCode);
|
||||
return await PermissionResetAsync(request.GroupCode);
|
||||
}
|
||||
|
||||
private async Task PermissionResetAsync(Guid groupCode)
|
||||
private async Task<DevicePermissionAssignResponse> PermissionResetAsync(Guid groupCode)
|
||||
{
|
||||
var deviceGroups = RecursionHelper.HandlerDeviceGroupPreviousCodes(groupCode, await _dbContext.Queryable<DeviceGroupEntity>().ToListAsync());
|
||||
|
||||
@@ -130,6 +130,8 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
.Where(x => deviceGroups.Contains(x.UniqueValue))
|
||||
.ToListAsync();
|
||||
|
||||
var result = new List<DevicePermissionAssignResponse>();
|
||||
|
||||
if (dps.Any())
|
||||
{
|
||||
var type = dps.First().Type;
|
||||
@@ -143,7 +145,7 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
|
||||
var codes = devicePermissionGroup.Select(x => x.UniqueValue).Distinct().ToList();
|
||||
|
||||
await analyzeService.AnalyzeAsync(new DevicePermissionSaveRequest
|
||||
var r = await analyzeService.AnalyzeAsync(new DevicePermissionSaveRequest
|
||||
{
|
||||
AssignType = assignType,
|
||||
AssignValue = assignValue,
|
||||
@@ -152,10 +154,12 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
TenantId = tenantId,
|
||||
Type = type
|
||||
});
|
||||
}
|
||||
|
||||
result.Add(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return new DevicePermissionAssignResponse(result.Sum(x => x.AddCount), result.Sum(x => x.DeleteCount));
|
||||
}
|
||||
|
||||
public async Task<List<DeviceUnderGroupResponse>> GetDevicesByGroupCodeAsync(Guid code)
|
||||
|
||||
@@ -18,10 +18,13 @@ public class GroupPermissionAnalyzeService : BasePermissionAnalyzeService
|
||||
var gainfoGroups = await DbContext.Queryable<GainfoGroupEntity>().ToListAsync();
|
||||
var gainfoGroupCodes = RecursionHelper.HandlerGainfoGroupNextCodes(code, gainfoGroups);
|
||||
|
||||
return await DbContext.Queryable<GainfoGroupRelationshipEntity>()
|
||||
var gainfoUserNos = await DbContext.Queryable<GainfoGroupRelationshipEntity>()
|
||||
.Where(x => gainfoGroupCodes.Contains(x.GroupCode))
|
||||
.Select(x => x.UserNo)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
return await DbContext.Queryable<GainfoEntity>().Where(x => gainfoUserNos.Contains(x.No)).Select(x => x.No).ToListAsync();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Basic.Device.Filters;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Basic.Organization.Services;
|
||||
@@ -76,8 +77,8 @@ public class GainfoGroupsController : ControllerBase
|
||||
[AssignPermissionLimit]
|
||||
[Transactional]
|
||||
[CrossTenant]
|
||||
public async Task AssignGainfosAsync(GainfoAssignRequest request)
|
||||
public async Task<DevicePermissionAssignResponse> AssignGainfosAsync(GainfoAssignRequest request)
|
||||
{
|
||||
await _gainfoGroupService.AssignGainfosAsync(request);
|
||||
return await _gainfoGroupService.AssignGainfosAsync(request);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Services;
|
||||
@@ -11,7 +12,7 @@ public interface IGainfoGroupService : IScopeDependency
|
||||
|
||||
Task<List<GainfoPageResponse>> GetGainfosByGroupAsync(Guid code);
|
||||
|
||||
Task AssignGainfosAsync(GainfoAssignRequest request);
|
||||
Task<DevicePermissionAssignResponse> AssignGainfosAsync(GainfoAssignRequest request);
|
||||
|
||||
Task<List<GainfoGroupTreeResponse>> GetGainfoGroupsByUserCodeAsync(string userCode);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Dlhis.Basic.Device;
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
@@ -75,7 +76,7 @@ public class GainfoGroupService : IGainfoGroupService
|
||||
return list;
|
||||
}
|
||||
|
||||
public async Task AssignGainfosAsync(GainfoAssignRequest request)
|
||||
public async Task<DevicePermissionAssignResponse> AssignGainfosAsync(GainfoAssignRequest request)
|
||||
{
|
||||
if (request.UserNos.IsPresent())
|
||||
{
|
||||
@@ -106,11 +107,11 @@ public class GainfoGroupService : IGainfoGroupService
|
||||
|
||||
await _dbContext.InsertAsync(entities);
|
||||
|
||||
await PermissionResetAsync(request.GroupCode);
|
||||
return await PermissionResetAsync(request.GroupCode);
|
||||
}
|
||||
|
||||
|
||||
private async Task PermissionResetAsync(Guid groupCode)
|
||||
private async Task<DevicePermissionAssignResponse> PermissionResetAsync(Guid groupCode)
|
||||
{
|
||||
var gainfoGroups = RecursionHelper.HandlerGainfoGroupPreviousCodes(groupCode, await _dbContext.Queryable<GainfoGroupEntity>().ToListAsync()).Select(x => x.ToString());
|
||||
|
||||
@@ -121,6 +122,8 @@ public class GainfoGroupService : IGainfoGroupService
|
||||
|
||||
var analyzeService = _namedResolver.GetService<IPermissionAnalyzeService>(PermissionAnalyzeConstants.GetTypeName(AssignTypeEnumType.Group));
|
||||
|
||||
var result = new List<DevicePermissionAssignResponse>();
|
||||
|
||||
foreach (var devicePermissionGroup in dps.GroupBy(x => new { x.AssignValue, x.TenantId, x.UniqueType, x.Type }))
|
||||
{
|
||||
var assignValue = devicePermissionGroup.Key.AssignValue;
|
||||
@@ -130,7 +133,7 @@ public class GainfoGroupService : IGainfoGroupService
|
||||
|
||||
var codes = devicePermissionGroup.Select(x => x.UniqueValue).Distinct().ToList();
|
||||
|
||||
await analyzeService.AnalyzeAsync(new DevicePermissionSaveRequest
|
||||
var r = await analyzeService.AnalyzeAsync(new DevicePermissionSaveRequest
|
||||
{
|
||||
AssignType = AssignTypeEnumType.Group,
|
||||
AssignValue = assignValue,
|
||||
@@ -139,7 +142,11 @@ public class GainfoGroupService : IGainfoGroupService
|
||||
TenantId = tenantId,
|
||||
Type = type
|
||||
});
|
||||
|
||||
result.Add(r);
|
||||
}
|
||||
|
||||
return new DevicePermissionAssignResponse(result.Sum(x => x.AddCount), result.Sum(x => x.DeleteCount));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user