Handler.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using Application.Abstractions.Messaging;
  2. using Application.Abstractions.Data;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace Application.Features.Config.Get;
  5. public sealed class Handler(IAppDbContext db) : IQueryHandler<Query, Response?>
  6. {
  7. public async Task<Response?> Handle(Query request, CancellationToken ct)
  8. {
  9. var config = await db.Config.AsNoTracking().OrderByDescending(x => x.ID).FirstOrDefaultAsync(ct);
  10. if (config is null)
  11. {
  12. return null;
  13. }
  14. return new Response
  15. {
  16. ID = config.ID,
  17. Basic = new Response.BasicConfigDto
  18. {
  19. SiteName = config.Basic.SiteName,
  20. SiteURL = config.Basic.SiteURL,
  21. RootID = config.Basic.RootID,
  22. FromEmail = config.Basic.FromEmail,
  23. FromName = config.Basic.FromName,
  24. SmtpServer = config.Basic.SmtpServer,
  25. SmtpPort = config.Basic.SmtpPort,
  26. SmtpEnableSSL = config.Basic.SmtpEnableSSL,
  27. SmtpUsername = config.Basic.SmtpUsername,
  28. SmtpPassword = config.Basic.SmtpPassword,
  29. AdminWhiteIPList = config.Basic.AdminWhiteIPList,
  30. FrontWhiteIPList = config.Basic.FrontWhiteIPList,
  31. BlockAlertTitle = config.Basic.BlockAlertTitle,
  32. BlockAlertContent = config.Basic.BlockAlertContent,
  33. IsMaintenance = config.Basic.IsMaintenance,
  34. MaintenanceContent = config.Basic.MaintenanceContent
  35. },
  36. Images = new Response.ImagesConfigDto
  37. {
  38. FaviconPath = config.Images.Favicon,
  39. LogoSquarePath = config.Images.LogoSquare,
  40. LogoHorizontalPath = config.Images.LogoHorizontal,
  41. OgDefaultPath = config.Images.OgDefault,
  42. TwitterImagePath = config.Images.TwitterImage,
  43. AppleTouchIconPath = config.Images.AppleTouchIcon,
  44. AppIcon192Path = config.Images.AppIcon_192,
  45. AppIcon512Path = config.Images.AppIcon_512
  46. },
  47. Meta = new Response.MetaConfigDto
  48. {
  49. Keywords = config.Meta.Keywords,
  50. Description = config.Meta.Description,
  51. Author = config.Meta.Author,
  52. Viewport = config.Meta.Viewport,
  53. ApplicationName = config.Meta.ApplicationName,
  54. Generator = config.Meta.Generator,
  55. Robots = config.Meta.Robots,
  56. Adds = config.Meta.Adds
  57. },
  58. Company = new Response.CompanyConfigDto
  59. {
  60. Name = config.Company.Name,
  61. RegNo = config.Company.RegNo,
  62. Address = config.Company.Address,
  63. ZipCode = config.Company.ZipCode,
  64. Owner = config.Company.Owner,
  65. Tel = config.Company.Tel,
  66. Fax = config.Company.Fax,
  67. RetailSaleNo = config.Company.RetailSaleNo,
  68. AddedSaleNo = config.Company.AddedSaleNo,
  69. Hosting = config.Company.Hosting,
  70. AdminName = config.Company.AdminName,
  71. AdminEmail = config.Company.AdminEmail,
  72. SiteUrl = config.Company.SiteUrl,
  73. BankCode = config.Company.BankCode,
  74. BankOwner = config.Company.BankOwner,
  75. BankNumber = config.Company.BankNumber
  76. },
  77. Account = new Response.AccountConfigDto
  78. {
  79. IsRegisterBlock = config.Account.IsRegisterBlock,
  80. IsRegisterEmailAuth = config.Account.IsRegisterEmailAuth,
  81. PasswordMinLength = config.Account.PasswordMinLength,
  82. PasswordUppercaseLength = config.Account.PasswordUppercaseLength,
  83. PasswordNumbersLength = config.Account.PasswordNumbersLength,
  84. PasswordSpecialcharsLength = config.Account.PasswordSpecialcharsLength,
  85. DeniedEmailList = config.Account.DeniedEmailList,
  86. DeniedNameList = config.Account.DeniedNameList,
  87. ChangeEmailDay = config.Account.ChangeEmailDay,
  88. ChangeNameDay = config.Account.ChangeNameDay,
  89. ChangeSummaryDay = config.Account.ChangeSummaryDay,
  90. ChangeIntroDay = config.Account.ChangeIntroDay,
  91. ChangePasswordDay = config.Account.ChangePasswordDay,
  92. MaxLoginTryCount = config.Account.MaxLoginTryCount,
  93. MaxLoginTryLimitSecond = config.Account.MaxLoginTryLimitSecond
  94. },
  95. EmailTemplate = new Response.EmailTemplateConfigDto
  96. {
  97. RegisterEmailFormTitle = config.EmailTemplate.RegisterEmailFormTitle,
  98. RegisterEmailFormContent = config.EmailTemplate.RegisterEmailFormContent,
  99. RegistrationEmailFormTitle = config.EmailTemplate.RegistrationEmailFormTitle,
  100. RegistrationEmailFormContent = config.EmailTemplate.RegistrationEmailFormContent,
  101. ResetPasswordEmailFormTitle = config.EmailTemplate.ResetPasswordEmailFormTitle,
  102. ResetPasswordEmailFormContent = config.EmailTemplate.ResetPasswordEmailFormContent,
  103. ChangedPasswordEmailFormTitle = config.EmailTemplate.ChangedPasswordEmailFormTitle,
  104. ChangedPasswordEmailFormContent = config.EmailTemplate.ChangedPasswordEmailFormContent,
  105. WithdrawEmailFormTitle = config.EmailTemplate.WithdrawEmailFormTitle,
  106. WithdrawEmailFormContent = config.EmailTemplate.WithdrawEmailFormContent,
  107. EmailVerifyFormTitle = config.EmailTemplate.EmailVerifyFormTitle,
  108. EmailVerifyFormContent = config.EmailTemplate.EmailVerifyFormContent,
  109. ChangedEmailFormTitle = config.EmailTemplate.ChangedEmailFormTitle,
  110. ChangedEmailFormContent = config.EmailTemplate.ChangedEmailFormContent
  111. },
  112. External = new Response.ExternalApiConfigDto
  113. {
  114. YouTubeApiKeyEnc = config.External.YouTubeApiKeyEnc,
  115. YouTubeApiName = config.External.YouTubeApiName,
  116. GoogleClientId = config.External.GoogleClientId,
  117. GoogleClientSecretEnc = config.External.GoogleClientSecretEnc,
  118. GoogleAppId = config.External.GoogleAppId
  119. },
  120. Payment = new Response.PaymentConfigDto
  121. {
  122. }
  123. };
  124. }
  125. }