ModelVoAdapt.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. using Common;
  2. using Dto.Admin;
  3. using Mapster;
  4. using Model;
  5. using Vo.Admin;
  6. namespace Util
  7. {
  8. public class ModelVoAdapt
  9. {
  10. public static void Map()
  11. {
  12. TypeAdapterConfig<AddProjectServiceDto, ProjectService>.NewConfig()
  13. .Map(dest => dest.serverList, src => src.serverList.Length == 0
  14. ? "" : string.Join(',', src.serverList))
  15. .Map(dest => dest.databaseList, src => src.databaseList.Length == 0
  16. ? "" : string.Join(',', src.databaseList));
  17. TypeAdapterConfig<ProjectService, GetProjectServiceQueryVo>.NewConfig()
  18. .Map(dest => dest.serverList, src => string.IsNullOrEmpty(src.serverList)
  19. ? Array.Empty<int>() : Tools.SpitIntArrary(src.serverList))
  20. .Map(dest => dest.databaseList, src => string.IsNullOrEmpty(src.databaseList)
  21. ? Array.Empty<int>() : Tools.SpitIntArrary(src.databaseList));
  22. TypeAdapterConfig<ProjectService, GetProjectServiceListVo>.NewConfig()
  23. .Map(dest => dest.serverList, src => string.IsNullOrEmpty(src.serverList)
  24. ? Array.Empty<int>() : Tools.SpitIntArrary(src.serverList))
  25. .Map(dest => dest.databaseList, src => string.IsNullOrEmpty(src.databaseList)
  26. ? Array.Empty<int>() : Tools.SpitIntArrary(src.databaseList));
  27. }
  28. }
  29. }