sunpengfei
2025-08-07 b4943813a032976e0febdd7f22d8bcf084e331c5
feat:字典开发
5个文件已修改
64 ■■■■ 已修改文件
FlexJobApi.Application/Dictionaries/Commands/DictionaryDataCommandHandler.cs 57 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
FlexJobApi.Core/Entities/Common/DictionaryData.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
FlexJobApi.Core/FlexJobApi.Core.csproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
FlexJobApi.Core/Models/Main/Dictionaries/Queries/GetDictionaryCategorySelectQuery.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
FlexJobApi.Core/Models/Main/Dictionaries/Queries/GetDictionaryDataSelectQuery.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
FlexJobApi.Application/Dictionaries/Commands/DictionaryDataCommandHandler.cs
@@ -1,5 +1,7 @@
using FlexJobApi.Core;
using EFCore.BulkExtensions;
using FlexJobApi.Core;
using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions;
using Furion.FriendlyException;
using Mapster;
using MediatR;
@@ -82,12 +84,55 @@
        public async Task<int> Handle(SyncHumanResourcesAreaDictionaryDataCommand request, CancellationToken cancellationToken)
        {
            var rep = Db.GetRepository<BaseArea, HumanResourcesDbContextLocator>();
            var areas = await rep.AsQueryable().AsNoTracking()
                .Take(10)
            var repHumanResourcesBaseArea = Db.GetRepository<BaseArea, HumanResourcesDbContextLocator>();
            var areas = await repHumanResourcesBaseArea.AsQueryable().AsNoTracking()
                .OrderBy(it => it.ParentId)
                .ToListAsync();
            Console.WriteLine();
            return 1;
            var entities = new List<DictionaryData>();
            var categoryId = new Guid("B21FE000-BB7F-4498-08E9-08DDD572EF73");
            await "DELETE FROM DictionaryData WHERE CategoryId = @CategoryId".SqlNonQueryAsync(new
            {
                CategoryId = categoryId
            });
            foreach (var area in areas)
            {
                var entity = new DictionaryData();
                entity.CategoryId = categoryId;
                entity.Id = area.Id;
                if (area.ParentId != 0)
                {
                    var parent = entities.FirstOrDefault(it => it.Field1 == area.ParentId.ToString());
                    if (parent == null)
                    {
                        var parentArea = areas.FirstOrDefault(it => it.AreaCode == area.ParentId);
                        if (parentArea != null)
                        {
                            throw Oops.Oh(EnumErrorCodeType.s404, "未找到上级地区");
                        }
                        else
                        {
                            continue;
                        }
                    }
                    entity.ParentId = parent.Id;
                    entity.Path = $"{parent.Path}{parent.Code}/";
                }
                else
                {
                    entity.Path = "/";
                }
                entity.Code = $"70-{area.AreaCode}";
                entity.Content = area.AreaName;
                entity.Field1 = area.AreaCode.ToString();
                entity.Field2 = area.QuickQuery;
                entity.Field3 = area.SimpleSpelling;
                entity.Field4 = area.Layer.ToString();
                entity.Field5 = area.Description;
                entity.Sort = area.Sort ?? 0;
                entities.Add(entity);
            }
            await rep.Context.BulkInsertAsync(entities);
            return entities.Count;
        }
    }
}
FlexJobApi.Core/Entities/Common/DictionaryData.cs
@@ -13,7 +13,7 @@
    /// <summary>
    /// 字典数据
    /// </summary>
    public class DictionaryData : CommonEntity, IEntityTypeBuilder<DictionaryData>, ITreeData<DictionaryData>, IIsDisabled
    public class DictionaryData : CommonEntity, IEntityTypeBuilder<DictionaryData>, ITreeData<DictionaryData>, IIsDisabled, IDbAuditLogIgnore
    {
        public DictionaryData()
        {
FlexJobApi.Core/FlexJobApi.Core.csproj
@@ -19,6 +19,7 @@
    <ItemGroup>
        <PackageReference Include="aliyun-net-sdk-core" Version="1.5.6" />
        <PackageReference Include="Consul" Version="1.7.14.8" />
        <PackageReference Include="EFCore.BulkExtensions" Version="9.0.1" />
        <PackageReference Include="Furion" Version="4.9.7.106" />
        <PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.7.106" />
        <PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.7.106" />
FlexJobApi.Core/Models/Main/Dictionaries/Queries/GetDictionaryCategorySelectQuery.cs
@@ -12,7 +12,7 @@
    /// <summary>
    /// 查询数据字典类别选择器数据
    /// </summary>
    [Resource([EnumResourceController.Dictionary])]
    [Resource([EnumResourceController.Dictionary], AllowAnonymous = false)]
    public class GetDictionaryCategorySelectQuery : SelectQuery<Guid, GetDictionaryCategorySelectQueryOption>
    {
    }
FlexJobApi.Core/Models/Main/Dictionaries/Queries/GetDictionaryDataSelectQuery.cs
@@ -10,7 +10,7 @@
    /// <summary>
    /// 查询数据字典选择器
    /// </summary>
    [Resource([EnumResourceController.Dictionary])]
    [Resource([EnumResourceController.Dictionary], AllowAnonymous = false)]
    public class GetDictionaryDataSelectQuery : SelectQuery<Guid, GetDictionaryDataSelectQueryResultOption>
    {
        /// <summary>