refactor 简单优化
- 使用DepartmentDto替换DepartmentEntity - 命名使用rider配置规范
This commit is contained in:
@@ -4,14 +4,14 @@ namespace Dlhis.Basic.Device;
|
|||||||
|
|
||||||
public static class PermissionAnalyzeConstants
|
public static class PermissionAnalyzeConstants
|
||||||
{
|
{
|
||||||
private const string _verb = "PermissionAnalyze";
|
private const string Verb = "PermissionAnalyze";
|
||||||
public const string User = nameof(AssignTypeEnumType.User) + _verb;
|
public const string User = nameof(AssignTypeEnumType.User) + Verb;
|
||||||
public const string Group = nameof(AssignTypeEnumType.Group) + _verb;
|
public const string Group = nameof(AssignTypeEnumType.Group) + Verb;
|
||||||
public const string Department = nameof(AssignTypeEnumType.Department) + _verb;
|
public const string Department = nameof(AssignTypeEnumType.Department) + Verb;
|
||||||
public const string Tenant = nameof(AssignTypeEnumType.Tenant) + _verb;
|
public const string Tenant = nameof(AssignTypeEnumType.Tenant) + Verb;
|
||||||
|
|
||||||
public static string GetTypeName(AssignTypeEnumType assignTypeEnumType)
|
public static string GetTypeName(AssignTypeEnumType assignTypeEnumType)
|
||||||
{
|
{
|
||||||
return assignTypeEnumType + _verb;
|
return assignTypeEnumType + Verb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using Dlhis.Basic.Device.Dtos;
|
using Dlhis.Basic.Device.Dtos;
|
||||||
using Dlhis.Basic.Device.Request;
|
using Dlhis.Basic.Device.Request;
|
||||||
using Dlhis.Basic.Device.Response;
|
using Dlhis.Basic.Device.Response;
|
||||||
|
using Dlhis.Basic.Organization.Dto;
|
||||||
using Dlhis.Entity.Basic.Entity;
|
using Dlhis.Entity.Basic.Entity;
|
||||||
using Dlhis.Entity.Basic.Enums;
|
using Dlhis.Entity.Basic.Enums;
|
||||||
using Dlhis.Entity.Device.Entities;
|
using Dlhis.Entity.Device.Entities;
|
||||||
@@ -306,7 +307,7 @@ public class DeviceGroupService : IDeviceGroupService
|
|||||||
.GroupBy(x => x.Factory)
|
.GroupBy(x => x.Factory)
|
||||||
.ToDictionary(x => x.Key, x => x.Select(p => p.DepartmentNo).Distinct().ToList());
|
.ToDictionary(x => x.Key, x => x.Select(p => p.DepartmentNo).Distinct().ToList());
|
||||||
|
|
||||||
var departments = await _dbContext.Queryable<DepartmentEntity>().ToListAsync();
|
var departments = await _dbContext.Queryable<DepartmentEntity>().Select<DepartmentDto>().ToListAsync();
|
||||||
|
|
||||||
var gainfoByDeptWhere = LinqExpressionExtensions.False<GainfoEntity>();
|
var gainfoByDeptWhere = LinqExpressionExtensions.False<GainfoEntity>();
|
||||||
foreach ((string factory, List<string> departmentNos) in tenantDepartmentNos)
|
foreach ((string factory, List<string> departmentNos) in tenantDepartmentNos)
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ public class DevicePermissionAnalyzeService : IDevicePermissionAnalyzeService
|
|||||||
var deviceRelationships = await _dbContext.Queryable<DeviceGroupRelationshipEntity>()
|
var deviceRelationships = await _dbContext.Queryable<DeviceGroupRelationshipEntity>()
|
||||||
.Where(x => x.IsDeleted == false)
|
.Where(x => x.IsDeleted == false)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
var departments = await _dbContext.Queryable<DepartmentEntity>().ToListAsync();
|
var departments = await _dbContext.Queryable<DepartmentEntity>().Select<DepartmentDto>().ToListAsync();
|
||||||
|
|
||||||
var result = new ConcurrentDictionary<string, List<TenantAssignTypeDeviceCode>>();
|
var result = new ConcurrentDictionary<string, List<TenantAssignTypeDeviceCode>>();
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ public class DevicePermissionAnalyzeService : IDevicePermissionAnalyzeService
|
|||||||
List<DevicePermissionDto> devicePermissions,
|
List<DevicePermissionDto> devicePermissions,
|
||||||
List<DeviceGroupEntity> deviceGroups,
|
List<DeviceGroupEntity> deviceGroups,
|
||||||
List<DeviceGroupRelationshipEntity> deviceGroupRelationships,
|
List<DeviceGroupRelationshipEntity> deviceGroupRelationships,
|
||||||
List<DepartmentEntity> departments)
|
List<DepartmentDto> departments)
|
||||||
{
|
{
|
||||||
var deviceDtos = new List<TenantAssignTypeDeviceCode>();
|
var deviceDtos = new List<TenantAssignTypeDeviceCode>();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Dlhis.Basic.Device.Dtos;
|
using Dlhis.Basic.Device.Dtos;
|
||||||
using Dlhis.Basic.Device.Request;
|
using Dlhis.Basic.Device.Request;
|
||||||
using Dlhis.Basic.Device.Response;
|
using Dlhis.Basic.Device.Response;
|
||||||
|
using Dlhis.Basic.Organization.Dto;
|
||||||
using Dlhis.Basic.Organization.Services;
|
using Dlhis.Basic.Organization.Services;
|
||||||
using Dlhis.Entity.Basic.Entity;
|
using Dlhis.Entity.Basic.Entity;
|
||||||
using Dlhis.Entity.Basic.Enums;
|
using Dlhis.Entity.Basic.Enums;
|
||||||
@@ -350,7 +351,7 @@ public class DevicePermissionService : IDevicePermissionService
|
|||||||
.SingleAsync();
|
.SingleAsync();
|
||||||
device.ThrowIfNull("设备不存在");
|
device.ThrowIfNull("设备不存在");
|
||||||
|
|
||||||
var departments = await _dbContext.Queryable<DepartmentEntity>().ToListAsync();
|
var departments = await _dbContext.Queryable<DepartmentEntity>().Select<DepartmentDto>().ToListAsync();
|
||||||
|
|
||||||
//当前设备的分组
|
//当前设备的分组
|
||||||
var groups = await _dbContext.Queryable<DeviceGroupRelationshipEntity>()
|
var groups = await _dbContext.Queryable<DeviceGroupRelationshipEntity>()
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Dlhis.Basic.Organization.Dto;
|
||||||
using Dlhis.Entity.Basic.Entity;
|
using Dlhis.Entity.Basic.Entity;
|
||||||
using Dlhis.Entity.Device.Enums;
|
using Dlhis.Entity.Device.Enums;
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ public class DepartmentPermissionAnalyzeService : BasePermissionAnalyzeService
|
|||||||
var factory = data[0];
|
var factory = data[0];
|
||||||
var departmentNo = data[1];
|
var departmentNo = data[1];
|
||||||
|
|
||||||
var departments = await DbContext.Queryable<DepartmentEntity>().ToListAsync();
|
var departments = await DbContext.Queryable<DepartmentEntity>().Select<DepartmentDto>().ToListAsync();
|
||||||
var departmentNos = RecursionHelper.HandlerDepartmentNextCodes(departmentNo, departments);
|
var departmentNos = RecursionHelper.HandlerDepartmentNextCodes(departmentNo, departments);
|
||||||
|
|
||||||
return await DbContext.Queryable<GainfoEntity>()
|
return await DbContext.Queryable<GainfoEntity>()
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
<DockerfileContext>..\..</DockerfileContext>
|
<DockerfileContext>..\..</DockerfileContext>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
<NoWarn>1701;1702;1591</NoWarn>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="log\**" />
|
<Compile Remove="log\**" />
|
||||||
<Content Remove="log\**" />
|
<Content Remove="log\**" />
|
||||||
|
|||||||
10
Src/Dlhis.Basic/Organization/Dto/DepartmentDto.cs
Normal file
10
Src/Dlhis.Basic/Organization/Dto/DepartmentDto.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace Dlhis.Basic.Organization.Dto;
|
||||||
|
|
||||||
|
public class DepartmentDto
|
||||||
|
{
|
||||||
|
public string No { get; set; }
|
||||||
|
|
||||||
|
public string PNo { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Dlhis.Basic.Organization.Dto;
|
||||||
using Dlhis.Entity.Basic.Entity;
|
using Dlhis.Entity.Basic.Entity;
|
||||||
using Dlhis.Entity.Device.Entities;
|
using Dlhis.Entity.Device.Entities;
|
||||||
using Kurisu.AspNetCore.Utils.Extensions;
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
@@ -47,7 +48,7 @@ public static class RecursionHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static List<string> HandlerDepartmentNextCodes(string current, List<DepartmentEntity> data)
|
public static List<string> HandlerDepartmentNextCodes(string current, List<DepartmentDto> data)
|
||||||
{
|
{
|
||||||
var result = new List<string> { current };
|
var result = new List<string> { current };
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ public static class RecursionHelper
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
static void InternalHandlerCodes(string internalCurrent, List<DepartmentEntity> internalData, List<string> internalResult)
|
static void InternalHandlerCodes(string internalCurrent, List<DepartmentDto> internalData, List<string> internalResult)
|
||||||
{
|
{
|
||||||
var next = internalData.Where(x => x.PNo == internalCurrent);
|
var next = internalData.Where(x => x.PNo == internalCurrent);
|
||||||
foreach (var item in next)
|
foreach (var item in next)
|
||||||
@@ -66,7 +67,7 @@ public static class RecursionHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<string> HandlerDepartmentPreviousCodes(string current, List<DepartmentEntity> data)
|
public static List<string> HandlerDepartmentPreviousCodes(string current, List<DepartmentDto> data)
|
||||||
{
|
{
|
||||||
var result = new List<string> { current };
|
var result = new List<string> { current };
|
||||||
|
|
||||||
@@ -74,7 +75,7 @@ public static class RecursionHelper
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
static void InternalHandlerCodes(string internalCurrent, List<DepartmentEntity> internalData, List<string> internalResult)
|
static void InternalHandlerCodes(string internalCurrent, List<DepartmentDto> internalData, List<string> internalResult)
|
||||||
{
|
{
|
||||||
var pno = internalData.FirstOrDefault(x => x.No == internalCurrent)?.PNo;
|
var pno = internalData.FirstOrDefault(x => x.No == internalCurrent)?.PNo;
|
||||||
if (pno.IsEmpty())
|
if (pno.IsEmpty())
|
||||||
|
|||||||
Reference in New Issue
Block a user