fix 查询json字段问题

This commit is contained in:
2024-07-22 15:38:27 +08:00
parent 42deb7925e
commit d27aa2e007
2 changed files with 23 additions and 3 deletions

View File

@@ -119,7 +119,7 @@ public class DevicePermissionService : IDevicePermissionService
public async Task<List<Guid>> GetAssignmentsAsync(DeviceGetAssignmentsRequest request)
{
var currentTenantId = request.TenantId ??= _currentUser.GetStringTenantId();
var currentTenantId = request.AssignType == AssignTypeEnumType.Department ? request.TenantId : _currentUser.GetStringTenantId();
var role = _currentUser.GetRole();
var isAll = role is "admin" or "tenant-admin";
var deviceCodes = _myDataPermissionService.GetMyDeviceCodes();

View File

@@ -87,7 +87,27 @@ public class DeviceTimePeriodService : IDeviceTimePeriodService
/// <inheritdoc />
public async Task<List<DeviceTimePeriodResponse>> GetListAsync(DeviceTimePeriodAssignEnumType assignType, Guid value)
{
return await _dbContext.Queryable<DeviceTimePeriodEntity>().Where(x => x.AssignType == assignType && x.Value == value).Select<DeviceTimePeriodResponse>().ToListAsync();
var data = await _dbContext.Queryable<DeviceTimePeriodEntity>()
.Where(x => x.AssignType == assignType && x.Value == value)
.Select<DeviceTimePeriodEntity>()
.ToListAsync();
var result = data.Adapt<List<DeviceTimePeriodResponse>>();
var values = data.Select(x => x.Value);
var assignData = assignType == DeviceTimePeriodAssignEnumType.Device
? await _dbContext.Queryable<DeviceEntity>().Where(x => values.Contains(x.Code)).Select(x => new { x.Code, Name = x.DeployPlace }).ToListAsync()
: await _dbContext.Queryable<DeviceTemplateEntity>().Where(x => values.Contains(x.Code)).Select(x => new { x.Code, x.Name }).ToListAsync();
var basicTypes = await _dbContext.Queryable<BasicTypeEntity>().Where(x => x.Type == "timeperiod").ToListAsync();
result.ForEach(item =>
{
item.Name = assignData.FirstOrDefault(x => x.Code == item.Value)?.Name;
item.CardTypeDesc = basicTypes.FirstOrDefault(x => x.Code == item.CardType.ToString())?.Display;
});
return result;
}
@@ -162,7 +182,7 @@ public class DeviceTimePeriodService : IDeviceTimePeriodService
Priority = 90,
TenantId = device.TenantId
});
break;
}
}