fix 框架tenant问题;档案组和设备组特殊处理返回
This commit is contained in:
@@ -5,8 +5,7 @@ using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.Core.User.Abstractions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
|
||||
@@ -16,21 +15,15 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly IDevicePermissionService _devicePermissionService;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
|
||||
public DeviceGroupService(IDbContext dbContext, IDevicePermissionService devicePermissionService)
|
||||
public DeviceGroupService(IDbContext dbContext, IDevicePermissionService devicePermissionService, ICurrentUser currentUser)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_devicePermissionService = devicePermissionService;
|
||||
_currentUser = currentUser;
|
||||
}
|
||||
|
||||
public async Task<Pagination<DeviceGroupPageResponse>> GetPageAsync(DeviceGroupPageRequest request)
|
||||
{
|
||||
return await _dbContext.Queryable<DeviceGroupEntity>()
|
||||
.WhereIF(request.Search.IsPresent(), x => x.Name.Contains(request.Search))
|
||||
.WhereIF(request.Type.HasValue, x => x.Type == request.Type)
|
||||
.Select<DeviceGroupPageResponse>()
|
||||
.ToPageListAsync(request);
|
||||
}
|
||||
|
||||
public async Task<List<DeviceGroupTreeResponse>> GetTreeAsync(bool showDevices, DeviceTypeEnumType? type)
|
||||
{
|
||||
@@ -206,15 +199,32 @@ public class DeviceGroupService : IDeviceGroupService
|
||||
/// 递归获取树
|
||||
/// </summary>
|
||||
/// <param name="current"></param>
|
||||
/// <param name="departments"></param>
|
||||
/// <param name="deviceGroups"></param>
|
||||
/// <param name="showDevices"></param>
|
||||
private void RecursionGetNext(DeviceGroupTreeResponse current, List<DeviceGroupTreeResponse> departments, bool showDevices)
|
||||
private void RecursionGetNext(DeviceGroupTreeResponse current, List<DeviceGroupTreeResponse> deviceGroups, bool showDevices)
|
||||
{
|
||||
var next = departments.Where(x => x.PCode == current.Code).ToList();
|
||||
var currentTenantId = _currentUser.GetStringTenantId();
|
||||
var next = deviceGroups.Where(x =>
|
||||
{
|
||||
if (x.PCode == current.Code)
|
||||
{
|
||||
if (x.TenantId.IsEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return x.TenantId == currentTenantId;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}).ToList();
|
||||
current.Next = next;
|
||||
foreach (var item in next)
|
||||
{
|
||||
RecursionGetNext(item, departments, showDevices);
|
||||
RecursionGetNext(item, deviceGroups, showDevices);
|
||||
}
|
||||
|
||||
//最后层级附加设备信息
|
||||
|
||||
Reference in New Issue
Block a user