refactor 简单优化

- 使用DepartmentDto替换DepartmentEntity
- 命名使用rider配置规范
This commit is contained in:
2025-06-23 14:58:10 +08:00
parent 4d8b7b5f16
commit e2f43cb01b
8 changed files with 33 additions and 15 deletions

View File

@@ -4,14 +4,14 @@ namespace Dlhis.Basic.Device;
public static class PermissionAnalyzeConstants
{
private const string _verb = "PermissionAnalyze";
public const string User = nameof(AssignTypeEnumType.User) + _verb;
public const string Group = nameof(AssignTypeEnumType.Group) + _verb;
public const string Department = nameof(AssignTypeEnumType.Department) + _verb;
public const string Tenant = nameof(AssignTypeEnumType.Tenant) + _verb;
private const string Verb = "PermissionAnalyze";
public const string User = nameof(AssignTypeEnumType.User) + Verb;
public const string Group = nameof(AssignTypeEnumType.Group) + Verb;
public const string Department = nameof(AssignTypeEnumType.Department) + Verb;
public const string Tenant = nameof(AssignTypeEnumType.Tenant) + Verb;
public static string GetTypeName(AssignTypeEnumType assignTypeEnumType)
{
return assignTypeEnumType + _verb;
return assignTypeEnumType + Verb;
}
}

View File

@@ -1,6 +1,7 @@
using Dlhis.Basic.Device.Dtos;
using Dlhis.Basic.Device.Request;
using Dlhis.Basic.Device.Response;
using Dlhis.Basic.Organization.Dto;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Basic.Enums;
using Dlhis.Entity.Device.Entities;
@@ -306,7 +307,7 @@ public class DeviceGroupService : IDeviceGroupService
.GroupBy(x => x.Factory)
.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>();
foreach ((string factory, List<string> departmentNos) in tenantDepartmentNos)

View File

@@ -113,7 +113,7 @@ public class DevicePermissionAnalyzeService : IDevicePermissionAnalyzeService
var deviceRelationships = await _dbContext.Queryable<DeviceGroupRelationshipEntity>()
.Where(x => x.IsDeleted == false)
.ToListAsync();
var departments = await _dbContext.Queryable<DepartmentEntity>().ToListAsync();
var departments = await _dbContext.Queryable<DepartmentEntity>().Select<DepartmentDto>().ToListAsync();
var result = new ConcurrentDictionary<string, List<TenantAssignTypeDeviceCode>>();
@@ -163,7 +163,7 @@ public class DevicePermissionAnalyzeService : IDevicePermissionAnalyzeService
List<DevicePermissionDto> devicePermissions,
List<DeviceGroupEntity> deviceGroups,
List<DeviceGroupRelationshipEntity> deviceGroupRelationships,
List<DepartmentEntity> departments)
List<DepartmentDto> departments)
{
var deviceDtos = new List<TenantAssignTypeDeviceCode>();

View File

@@ -1,6 +1,7 @@
using Dlhis.Basic.Device.Dtos;
using Dlhis.Basic.Device.Request;
using Dlhis.Basic.Device.Response;
using Dlhis.Basic.Organization.Dto;
using Dlhis.Basic.Organization.Services;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Basic.Enums;
@@ -350,7 +351,7 @@ public class DevicePermissionService : IDevicePermissionService
.SingleAsync();
device.ThrowIfNull("设备不存在");
var departments = await _dbContext.Queryable<DepartmentEntity>().ToListAsync();
var departments = await _dbContext.Queryable<DepartmentEntity>().Select<DepartmentDto>().ToListAsync();
//当前设备的分组
var groups = await _dbContext.Queryable<DeviceGroupRelationshipEntity>()

View File

@@ -1,3 +1,4 @@
using Dlhis.Basic.Organization.Dto;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Device.Enums;
@@ -18,7 +19,7 @@ public class DepartmentPermissionAnalyzeService : BasePermissionAnalyzeService
var factory = data[0];
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);
return await DbContext.Queryable<GainfoEntity>()

View File

@@ -9,6 +9,10 @@
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Remove="log\**" />
<Content Remove="log\**" />

View 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; }
}

View File

@@ -1,3 +1,4 @@
using Dlhis.Basic.Organization.Dto;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Device.Entities;
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 };
@@ -55,7 +56,7 @@ public static class RecursionHelper
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);
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 };
@@ -74,7 +75,7 @@ public static class RecursionHelper
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;
if (pno.IsEmpty())