From fc73d4d85c68c8a9682dddbc7796fee95b0d2495 Mon Sep 17 00:00:00 2001 From: xiaolipro <2357729423@qq.com> Date: Tue, 29 Jul 2025 16:13:50 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=A1=AB=E8=A1=A5=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1=E7=9A=84object=20map?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoMapper/AppProfile.cs | 5 ++ .../AutoMapper/ParameterProfile.cs | 1 + .../Interface/SystemInterfaceService.cs | 25 +++++--- .../ValueObjects/SystemInterfaceOutput.cs | 61 ++++++++++++++++++- 4 files changed, 79 insertions(+), 13 deletions(-) diff --git a/src/InterfaceForward.Application/AutoMapper/AppProfile.cs b/src/InterfaceForward.Application/AutoMapper/AppProfile.cs index 7be97a3..f661286 100644 --- a/src/InterfaceForward.Application/AutoMapper/AppProfile.cs +++ b/src/InterfaceForward.Application/AutoMapper/AppProfile.cs @@ -1,5 +1,6 @@ using AutoMapper; using InterfaceForward.Application.Contracts.Dtos.App; +using InterfaceForward.Application.HostServices; using InterfaceForward.Repositories.App.Entitys; namespace InterfaceForward.Application.AutoMapper; @@ -11,5 +12,9 @@ internal class AppProfile : Profile CreateMap(MemberList.None); CreateMap(MemberList.None); CreateMap(MemberList.None); + + CreateMap(MemberList.None); + CreateMap(MemberList.None); + CreateMap(MemberList.None); } } \ No newline at end of file diff --git a/src/InterfaceForward.Application/AutoMapper/ParameterProfile.cs b/src/InterfaceForward.Application/AutoMapper/ParameterProfile.cs index d0f2c29..9374dcc 100644 --- a/src/InterfaceForward.Application/AutoMapper/ParameterProfile.cs +++ b/src/InterfaceForward.Application/AutoMapper/ParameterProfile.cs @@ -15,6 +15,7 @@ public class ParameterProfile: Profile public ParameterProfile() { CreateMap(MemberList.None); + CreateMap(MemberList.None); CreateMap(MemberList.None); CreateMap(MemberList.None) .ForMember(dest => dest.Id, diff --git a/src/InterfaceForward.Application/Services/Interface/SystemInterfaceService.cs b/src/InterfaceForward.Application/Services/Interface/SystemInterfaceService.cs index 2218d07..186bbb2 100644 --- a/src/InterfaceForward.Application/Services/Interface/SystemInterfaceService.cs +++ b/src/InterfaceForward.Application/Services/Interface/SystemInterfaceService.cs @@ -9,6 +9,7 @@ using InterfaceForward.Repositories; using InterfaceForward.Repositories.Interface.Entitys; using InterfaceForward.Repositories.Interface.Services; using InterfaceForward.Repositories.Interface.ValueObjects; +using InterfaceForward.Repositories.Parameter.VO; using Microsoft.AspNetCore.Mvc; namespace InterfaceForward.Application.Services.Interface; @@ -45,8 +46,8 @@ public class SystemInterfaceService : ApplicationService } #endregion - - + + /// /// 系统接口分页列表 /// @@ -69,9 +70,9 @@ public class SystemInterfaceService : ApplicationService GetSystemInterfaceTreeListAsync(SystemInterfaceTreeListInputObjectValue input) { var res = await _interfaceRepository.GetSystemInterfaceListAsync(input); - + var tree = await _interfaceCategoryService.GetCategoryTree(true, res); - + return tree; } @@ -95,9 +96,13 @@ public class SystemInterfaceService : ApplicationService // 构造参数 var paras = await _interfaceRepository.GetParameterListByIdAsync(id); // 入参树形列表 - res.InParameterList = paras.Where(x => x.IsInPara).ToList(); + res.InParameterList = + ObjectMapper.Map, List>( + paras.Where(x => x.IsInPara).ToList()); // 出参树形列表 - res.OutParameterList = paras.Where(x => !x.IsInPara).ToList(); + res.OutParameterList = + ObjectMapper.Map, List>( + paras.Where(x => !x.IsInPara).ToList()); return res; } @@ -137,10 +142,10 @@ public class SystemInterfaceService : ApplicationService switch (input.OptionType) { case OptionType.新增: - await CreateSystemInterfaceAsync(input); + await CreateSystemInterfaceAsync(input); break; case OptionType.修改: - await UpdateSystemInterfaceAsync(input); + await UpdateSystemInterfaceAsync(input); break; case OptionType.删除: await BatchDeleteSystemInterfaceByIdsAsync(new List { input.Id ?? 0 }); @@ -173,6 +178,7 @@ public class SystemInterfaceService : ApplicationService { await _interfaceMapRepository.SoftDeleteAsync(x => mapIds.Contains(x.Id)); } + // 删缓存 await RedisHelper.Client.DelAsync(SystemInterfaceDropdownCacheKey); @@ -205,8 +211,7 @@ public class SystemInterfaceService : ApplicationService throw new BusinessException(message: $"接口名:{input.Name} 已存在"); } - if (await _interfaceRepository.IsAnyAsync( - x => x.Id != input.Id && x.IsUpStream && x.Code.Equals(input.Code))) + if (await _interfaceRepository.IsAnyAsync(x => x.Id != input.Id && x.IsUpStream && x.Code.Equals(input.Code))) { throw new BusinessException(message: "接口code已存在"); } diff --git a/src/InterfaceForward.Repositories/Interface/ValueObjects/SystemInterfaceOutput.cs b/src/InterfaceForward.Repositories/Interface/ValueObjects/SystemInterfaceOutput.cs index b93e65e..5cc9447 100644 --- a/src/InterfaceForward.Repositories/Interface/ValueObjects/SystemInterfaceOutput.cs +++ b/src/InterfaceForward.Repositories/Interface/ValueObjects/SystemInterfaceOutput.cs @@ -1,4 +1,5 @@ -using InterfaceForward.Repositories.Parameter.VO; +using System.Text.Json.Serialization; +using InterfaceForward.Repositories.Parameter.VO; namespace InterfaceForward.Repositories.Interface.ValueObjects; @@ -65,10 +66,64 @@ public class SystemInterfaceOutput /// /// 入参列表 /// - public List InParameterList { get; set; } + public List InParameterList { get; set; } /// /// 出参列表 /// - public List OutParameterList { get; set; } + public List OutParameterList { get; set; } +} + +public class InterfaceParameterOutput +{ + /// + /// Id + /// + public int Id { get; set; } + + /// + /// 父级Id + /// + public int PId { get; set; } + + /// + /// 别名 + /// + public string Alias { get; set; } + + /// + /// 参数名 + /// + public string Name { get; set; } + + /// + /// 参数名(中文) + /// + public string CnName { get; set; } + + /// + /// 参数类型 + /// + public int Type { get; set; } + + /// + /// 是否必填 + /// + public bool IsRequired { get; set; } + + /// + /// 参数描述 + /// + public string Description { get; set; } + + /// + /// 0:返回参数;1:请求参数 + /// + public bool IsInPara { get; set; } + + /// + /// 序列 + /// + [JsonIgnore] + public string Sort { get; set; } } \ No newline at end of file