From 7a57112e0bda1631265ff0c0710921db56fa1c94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96ZT=C3=9CRK?= <76204082+iamsedatozturk@users.noreply.github.com> Date: Wed, 20 Aug 2025 13:31:56 +0300 Subject: [PATCH] =?UTF-8?q?t=C3=BCm=20public=20servisler=20birle=C5=9Ftiri?= =?UTF-8?q?ldi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Blog/IBlogAppService.cs | 3 - .../Blog/BlogAppService.cs | 203 ++----------- .../Blog/BlogAutoMapperProfile.cs | 16 -- .../Demo/DemoAppService.cs | 58 ---- .../Demo/DemoAutoMapperProfile.cs | 12 - .../Orders/OrderAppService.cs | 113 -------- .../Orders/OrderAutoMapperProfile.cs | 15 - .../Public/PublicAppService.cs | 271 ++++++++++++++++++ .../Public/PublicAutoMapperProfile.cs | 24 ++ .../Services/ServiceAppService.cs | 26 -- .../Services/ServiceAutoMapperProfile.cs | 13 - api/src/Kurs.Platform.Domain/Orders/Order.cs | 3 +- ui/src/services/blog.service.ts | 20 +- ui/src/services/demo.service.ts | 4 +- ui/src/services/order.service.ts | 8 +- ui/src/services/service.service.ts | 2 +- 16 files changed, 325 insertions(+), 466 deletions(-) delete mode 100644 api/src/Kurs.Platform.Application/Blog/BlogAutoMapperProfile.cs delete mode 100644 api/src/Kurs.Platform.Application/Demo/DemoAppService.cs delete mode 100644 api/src/Kurs.Platform.Application/Demo/DemoAutoMapperProfile.cs delete mode 100644 api/src/Kurs.Platform.Application/Orders/OrderAppService.cs delete mode 100644 api/src/Kurs.Platform.Application/Orders/OrderAutoMapperProfile.cs create mode 100644 api/src/Kurs.Platform.Application/Public/PublicAppService.cs create mode 100644 api/src/Kurs.Platform.Application/Public/PublicAutoMapperProfile.cs delete mode 100644 api/src/Kurs.Platform.Application/Services/ServiceAppService.cs delete mode 100644 api/src/Kurs.Platform.Application/Services/ServiceAutoMapperProfile.cs diff --git a/api/src/Kurs.Platform.Application.Contracts/Blog/IBlogAppService.cs b/api/src/Kurs.Platform.Application.Contracts/Blog/IBlogAppService.cs index 5ff41101..702f4982 100644 --- a/api/src/Kurs.Platform.Application.Contracts/Blog/IBlogAppService.cs +++ b/api/src/Kurs.Platform.Application.Contracts/Blog/IBlogAppService.cs @@ -9,9 +9,6 @@ namespace Kurs.Platform.Blog; public interface IBlogAppService : IApplicationService { // Blog Post methods - Task GetPostListAsync(GetBlogPostsInput input); - Task GetPostAsync(Guid id); - Task GetPostBySlugAsync(string slug); Task CreatePostAsync(CreateUpdateBlogPostDto input); Task UpdatePostAsync(Guid id, CreateUpdateBlogPostDto input); Task DeletePostAsync(Guid id); diff --git a/api/src/Kurs.Platform.Application/Blog/BlogAppService.cs b/api/src/Kurs.Platform.Application/Blog/BlogAppService.cs index 86e19be3..e71645ca 100644 --- a/api/src/Kurs.Platform.Application/Blog/BlogAppService.cs +++ b/api/src/Kurs.Platform.Application/Blog/BlogAppService.cs @@ -1,13 +1,9 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using Kurs.Platform.Entities; using Kurs.Platform.Localization; using Microsoft.AspNetCore.Authorization; using Microsoft.Extensions.Localization; -using Volo.Abp.Application.Dtos; -using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories; using Volo.Abp.Users; @@ -33,160 +29,6 @@ public class BlogAppService : PlatformAppService, IBlogAppService _localizer = localizer; } - // Blog Post methods - [AllowAnonymous] - public async Task GetPostListAsync(GetBlogPostsInput input) - { - // IQueryable - var postQuery = await _postRepository.GetQueryableAsync(); - - // 🔎 Arama - if (!input.Search.IsNullOrWhiteSpace()) - { - postQuery = postQuery.Where(p => - p.ContentTr.Contains(input.Search) || - p.ContentEn.Contains(input.Search)); - } - - // 📁 Kategori filtresi - if (input.CategoryId.HasValue) - { - postQuery = postQuery.Where(p => p.CategoryId == input.CategoryId.Value); - } - - // Toplam adet (sayfalama öncesi) - var totalCount = await AsyncExecuter.CountAsync(postQuery); - - // Sayfalama + sıralama - var pagedPosts = await AsyncExecuter.ToListAsync( - postQuery - .OrderByDescending(p => p.CreationTime) - .PageBy(input) - ); - - // Sayfadaki kategori kayıtları - var categoryIds = pagedPosts.Select(x => x.CategoryId).Distinct().ToList(); - var pageCategories = await _categoryRepository.GetListAsync(x => categoryIds.Contains(x.Id)); - var categoryDict = pageCategories.ToDictionary(x => x.Id, x => x); - - // Post DTO mapping - var postDtos = pagedPosts.Select(post => - { - var dto = ObjectMapper.Map(post); - if (categoryDict.TryGetValue(post.CategoryId, out var c)) - { - dto.Category = ObjectMapper.Map(c); - } - - dto.Author = new AuthorDto { Id = post.AuthorId, Name = "User" }; - return dto; - }).ToList(); - - // ----------- KATEGORİLER (PostCount ile) ----------- - var allCategories = await _categoryRepository.GetListAsync(); - - var allPostQuery = await _postRepository.GetQueryableAsync(); - var counts = await AsyncExecuter.ToListAsync( - allPostQuery - .Where(p => p.IsPublished) - .GroupBy(p => p.CategoryId) - .Select(g => new { g.Key, Count = g.Count() }) - ); - - var countDict = counts.ToDictionary(x => x.Key, x => x.Count); - - var categoryDtos = ObjectMapper.Map, List>(allCategories); - foreach (var dto in categoryDtos) - { - dto.PostCount = countDict.GetOrDefault(dto.Id); - } - - return new BlogPostAndCategoriesDto - { - Posts = new PagedResultDto(totalCount, postDtos), - Categories = categoryDtos - }; - } - - // public async Task> GetPostsAsync(GetBlogPostsInput input) - // { - // var allPosts = await _postRepository.GetListAsync(); // Tüm kayıtlar memory'ye alınır - // var filtered = allPosts.Where(post => - // { - // var searchMatch = string.IsNullOrWhiteSpace(input.Search) || - // post.ContentTr.Contains(input.Search, StringComparison.OrdinalIgnoreCase) || - // post.ContentEn.Contains(input.Search, StringComparison.OrdinalIgnoreCase); - - // var categoryMatch = !input.CategoryId.HasValue || post.CategoryId == input.CategoryId.Value; - - // return searchMatch && categoryMatch; - // }).ToList(); - - // var totalCount = filtered.Count; - // var pagedPosts = filtered - // .OrderByDescending(x => x.CreationTime) - // .Skip(input.SkipCount) - // .Take(input.MaxResultCount) - // .ToList(); - - // var categoryIds = pagedPosts.Select(x => x.CategoryId).Distinct().ToList(); - // var categories = await _categoryRepository.GetListAsync(x => categoryIds.Contains(x.Id)); - // var categoryDict = categories.ToDictionary(x => x.Id, x => x); - - // var postIds = pagedPosts.Select(x => x.Id).ToList(); - // var postDtos = pagedPosts.Select(post => - // { - // var dto = ObjectMapper.Map(post); - // if (categoryDict.TryGetValue(post.CategoryId, out var category)) - // { - // dto.Category = ObjectMapper.Map(category); - // } - - // dto.Author = new AuthorDto - // { - // Id = post.AuthorId, - // Name = "User" - // }; - - // return dto; - // }).ToList(); - - // return new PagedResultDto(totalCount, postDtos); - // } - - [AllowAnonymous] - public async Task GetPostAsync(Guid id) - { - var post = await _postRepository.GetAsync(id); - var dto = ObjectMapper.Map(post); - - // Get category - dto.Category = ObjectMapper.Map( - await _categoryRepository.GetAsync(post.CategoryId) - ); - - // Get author info - dto.Author = new AuthorDto - { - Id = post.AuthorId, - Name = "User" - }; - - return dto; - } - - [AllowAnonymous] - public async Task GetPostBySlugAsync(string slug) - { - var post = await _postRepository.FirstOrDefaultAsync(x => x.Slug == slug); - if (post == null) - { - throw new EntityNotFoundException(typeof(BlogPost)); - } - - return await GetPostAsync(post.Id); - } - public async Task CreatePostAsync(CreateUpdateBlogPostDto input) { var post = new BlogPost( @@ -210,6 +52,26 @@ public class BlogAppService : PlatformAppService, IBlogAppService return await GetPostAsync(post.Id); } + private async Task GetPostAsync(Guid id) + { + var post = await _postRepository.GetAsync(id); + var dto = ObjectMapper.Map(post); + + // Get category + dto.Category = ObjectMapper.Map( + await _categoryRepository.GetAsync(post.CategoryId) + ); + + // Get author info + dto.Author = new AuthorDto + { + Id = post.AuthorId, + Name = "User" + }; + + return dto; + } + public async Task UpdatePostAsync(Guid id, CreateUpdateBlogPostDto input) { var post = await _postRepository.GetAsync(id); @@ -296,31 +158,6 @@ public class BlogAppService : PlatformAppService, IBlogAppService return await GetPostAsync(id); } - // // Blog Category methods - // [AllowAnonymous] - // public async Task> GetCategoriesAsync() - // { - // var categories = await _categoryRepository.GetListAsync(); - - // var postQuery = await _postRepository.GetQueryableAsync(); - - // var groupedCounts = postQuery - // .Where(p => p.IsPublished) // sadece yayınlanmış yazılar - // .GroupBy(p => p.CategoryId) - // .Select(g => new { CategoryId = g.Key, Count = g.Count() }) - // .ToList(); - - // var dtoList = ObjectMapper.Map, List>(categories); - - // foreach (var dto in dtoList) - // { - // dto.PostCount = groupedCounts - // .FirstOrDefault(x => x.CategoryId == dto.Id)?.Count ?? 0; - // } - - // return dtoList; - // } - public async Task GetCategoryAsync(Guid id) { var category = await _categoryRepository.GetAsync(id); diff --git a/api/src/Kurs.Platform.Application/Blog/BlogAutoMapperProfile.cs b/api/src/Kurs.Platform.Application/Blog/BlogAutoMapperProfile.cs deleted file mode 100644 index dcdc6c5f..00000000 --- a/api/src/Kurs.Platform.Application/Blog/BlogAutoMapperProfile.cs +++ /dev/null @@ -1,16 +0,0 @@ -using AutoMapper; -using Kurs.Platform.Blog; -using Kurs.Platform.Entities; - -namespace Kurs.Platform; - -public class BlogAutoMapperProfile : Profile -{ - public BlogAutoMapperProfile() - { - // Blog mappings - CreateMap(); - CreateMap(); - CreateMap(); - } -} diff --git a/api/src/Kurs.Platform.Application/Demo/DemoAppService.cs b/api/src/Kurs.Platform.Application/Demo/DemoAppService.cs deleted file mode 100644 index a41a0db6..00000000 --- a/api/src/Kurs.Platform.Application/Demo/DemoAppService.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; -using Kurs.Platform.Data.Seeds; -using Kurs.Platform.Entities; -using Kurs.Sender.Mail; -using Microsoft.AspNetCore.Authorization; -using Volo.Abp.Domain.Repositories; -using Volo.Abp.Settings; - -namespace Kurs.Platform.Demos; - -public class DemoAppService : PlatformAppService -{ - private readonly ISettingProvider _settingProvider; - private readonly IKursEmailSender _emailSender; - private readonly IRepository _repository; - - public DemoAppService( - ISettingProvider settingProvider, - IKursEmailSender emailSender, - IRepository repository - ) - { - _settingProvider = settingProvider; - _emailSender = emailSender; - _repository = repository; - } - - [AllowAnonymous] - public async Task CreateDemoAsync(DemoDto input) - { - var demo = ObjectMapper.Map(input); - await _repository.InsertAsync(demo); - - var bodyBuilder = new StringBuilder(); - bodyBuilder.AppendLine($"Şirket: {input.OrganizationName}"); - bodyBuilder.AppendLine($"Ad Soyad: {input.FullName}"); - bodyBuilder.AppendLine($"E-Posta: {input.Email}"); - bodyBuilder.AppendLine($"Telefon: {input.Phone}"); - bodyBuilder.AppendLine($"Adres: {input.Address}"); - bodyBuilder.AppendLine($"Şube Sayısı: {input.NumberOfBranches}"); - bodyBuilder.AppendLine($"Kullanıcı Sayısı: {input.NumberOfUsers}"); - bodyBuilder.AppendLine($"Mesaj: {input.Message}"); - - var SenderName = await _settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromDisplayName); - var SenderEmailAddress = await _settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromAddress); - - await _emailSender.QueueEmailAsync( - SenderEmailAddress, - new KeyValuePair(SenderName, SenderEmailAddress), - null, - bodyBuilder.ToString(), - subject: PlatformConsts.AppName + " : Demo Talebi"); - - } -} diff --git a/api/src/Kurs.Platform.Application/Demo/DemoAutoMapperProfile.cs b/api/src/Kurs.Platform.Application/Demo/DemoAutoMapperProfile.cs deleted file mode 100644 index 153c2170..00000000 --- a/api/src/Kurs.Platform.Application/Demo/DemoAutoMapperProfile.cs +++ /dev/null @@ -1,12 +0,0 @@ -using AutoMapper; -using Kurs.Platform.Entities; - -namespace Kurs.Platform.Demos; - -public class DemoAutoMapperProfile : Profile -{ - public DemoAutoMapperProfile() - { - CreateMap().ReverseMap(); - } -} diff --git a/api/src/Kurs.Platform.Application/Orders/OrderAppService.cs b/api/src/Kurs.Platform.Application/Orders/OrderAppService.cs deleted file mode 100644 index 14dd6f34..00000000 --- a/api/src/Kurs.Platform.Application/Orders/OrderAppService.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using Volo.Abp.Domain.Repositories; -using Kurs.Platform.Entities; -using System.Threading.Tasks; -using Volo.Abp.Application.Services; -using System.Collections.Generic; -using System.Linq; -using Newtonsoft.Json; - -namespace Kurs.Platform.Orders; - -public interface IOrderAppService : IApplicationService -{ - Task> GetProductListAsync(); - Task> GetPaymentMethodListAsync(); - Task> GetInstallmentOptionListAsync(); - - Task CreateAsync(OrderDto input); -} - -public class OrderAppService : ApplicationService, IOrderAppService -{ - private readonly IRepository _productRepository; - private readonly IRepository _paymentMethodRepository; - private readonly IRepository _installmentOptionRepository; - private readonly IRepository _orderRepository; - - public OrderAppService(IRepository productRepository, - IRepository paymentMethodRepository, - IRepository installmentOptionRepository, - IRepository orderRepository) - { - _productRepository = productRepository; - _paymentMethodRepository = paymentMethodRepository; - _installmentOptionRepository = installmentOptionRepository; - _orderRepository = orderRepository; - } - - public async Task> GetProductListAsync() - { - var products = await _productRepository.GetListAsync(); - - return ObjectMapper.Map, List>(products.OrderBy(p => p.Order).ToList()); - } - - public async Task> GetPaymentMethodListAsync() - { - var paymentMethods = await _paymentMethodRepository.GetListAsync(); - - return ObjectMapper.Map, List>(paymentMethods); - } - - public async Task> GetInstallmentOptionListAsync() - { - var installmentOptions = await _installmentOptionRepository.GetListAsync(); - - return ObjectMapper.Map, List>(installmentOptions); - } - - public async Task CreateAsync(OrderDto input) - { - var entity = new Order() - { - TenantId = input.Tenant.Id, - InstitutionName = input.Tenant.InstitutionName, - Founder = input.Tenant.Founder, - VknTckn = input.Tenant.VknTckn, - TaxOffice = input.Tenant.TaxOffice, - Address = input.Tenant.Address, - Address2 = input.Tenant.Address2, - District = input.Tenant.District, - Country = input.Tenant.Country, - City = input.Tenant.City, - PostalCode = input.Tenant.PostalCode, - Phone = input.Tenant.Phone, - Mobile = input.Tenant.Mobile, - Fax = input.Tenant.Fax, - Email = input.Tenant.Email, - Website = input.Tenant.Website, - - Subtotal = input.Subtotal, - Commission = input.Commission, - Total = input.Total, - PaymentMethod = input.PaymentMethod, - Installments = input.Installments, - InstallmentName = input.InstallmentName, - PaymentDataJson = JsonConvert.SerializeObject(input.PaymentData), - }; - - foreach (var item in input.Items) - { - entity.Items.Add(new OrderItem - { - OrderId = entity.Id, - Order = entity, - ProductId = item.Product.Id, - ProductName = item.Product.Name, - BillingCycle = item.BillingCycle, - Quantity = item.Quantity, - TotalPrice = item.TotalPrice - }); - } - - await _orderRepository.InsertAsync(entity, autoSave: true); - - return new OrderDto - { - Id = entity.Id, - Total = entity.Total, - PaymentMethod = entity.PaymentMethod - }; - } -} diff --git a/api/src/Kurs.Platform.Application/Orders/OrderAutoMapperProfile.cs b/api/src/Kurs.Platform.Application/Orders/OrderAutoMapperProfile.cs deleted file mode 100644 index 407fb1bc..00000000 --- a/api/src/Kurs.Platform.Application/Orders/OrderAutoMapperProfile.cs +++ /dev/null @@ -1,15 +0,0 @@ -using AutoMapper; -using Kurs.Platform.Entities; - -namespace Kurs.Platform.Orders; - -public class OrderApplicationAutoMapperProfile : Profile -{ - public OrderApplicationAutoMapperProfile() - { - CreateMap().ReverseMap(); - CreateMap(); - CreateMap(); - CreateMap(); - } -} diff --git a/api/src/Kurs.Platform.Application/Public/PublicAppService.cs b/api/src/Kurs.Platform.Application/Public/PublicAppService.cs new file mode 100644 index 00000000..655c0879 --- /dev/null +++ b/api/src/Kurs.Platform.Application/Public/PublicAppService.cs @@ -0,0 +1,271 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Kurs.Platform.Entities; +using Kurs.Platform.Services; +using Volo.Abp.Domain.Repositories; +using System.Text; +using Kurs.Platform.Data.Seeds; +using Kurs.Sender.Mail; +using Volo.Abp.Settings; +using Kurs.Platform.Demos; +using Kurs.Platform.Blog; +using Volo.Abp.Domain.Entities; +using System.Linq; +using Volo.Abp.Application.Dtos; +using Kurs.Platform.Orders; +using System.Text.Json; + +namespace Kurs.Platform.Public; + +public class PublicAppService : PlatformAppService +{ + private readonly IRepository _serviceRepository; + private readonly ISettingProvider _settingProvider; + private readonly IKursEmailSender _emailSender; + private readonly IRepository _demoRepository; + private readonly IRepository _postRepository; + private readonly IRepository _categoryRepository; + private readonly IRepository _productRepository; + private readonly IRepository _paymentMethodRepository; + private readonly IRepository _installmentOptionRepository; + private readonly IRepository _orderRepository; + + public PublicAppService( + IRepository serviceRepository, + ISettingProvider settingProvider, + IKursEmailSender emailSender, + IRepository demoRepository, + IRepository postRepository, + IRepository categoryRepository, + IRepository productRepository, + IRepository paymentMethodRepository, + IRepository installmentOptionRepository, + IRepository orderRepository + ) + { + _serviceRepository = serviceRepository; + _settingProvider = settingProvider; + _emailSender = emailSender; + _demoRepository = demoRepository; + _postRepository = postRepository; + _categoryRepository = categoryRepository; + _productRepository = productRepository; + _paymentMethodRepository = paymentMethodRepository; + _installmentOptionRepository = installmentOptionRepository; + _orderRepository = orderRepository; + } + + public async Task> GetServicesListAsync() + { + var entity = await _serviceRepository.GetListAsync(); + + return ObjectMapper.Map, List>(entity); + } + + public async Task CreateDemoAsync(DemoDto input) + { + var demo = ObjectMapper.Map(input); + await _demoRepository.InsertAsync(demo); + + var bodyBuilder = new StringBuilder(); + bodyBuilder.AppendLine($"Şirket: {input.OrganizationName}"); + bodyBuilder.AppendLine($"Ad Soyad: {input.FullName}"); + bodyBuilder.AppendLine($"E-Posta: {input.Email}"); + bodyBuilder.AppendLine($"Telefon: {input.Phone}"); + bodyBuilder.AppendLine($"Adres: {input.Address}"); + bodyBuilder.AppendLine($"Şube Sayısı: {input.NumberOfBranches}"); + bodyBuilder.AppendLine($"Kullanıcı Sayısı: {input.NumberOfUsers}"); + bodyBuilder.AppendLine($"Mesaj: {input.Message}"); + + var SenderName = await _settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromDisplayName); + var SenderEmailAddress = await _settingProvider.GetOrNullAsync(SeedConsts.AbpSettings.Mailing.Default.DefaultFromAddress); + + await _emailSender.QueueEmailAsync( + SenderEmailAddress, + new KeyValuePair(SenderName, SenderEmailAddress), + null, + bodyBuilder.ToString(), + subject: PlatformConsts.AppName + " : Demo Talebi"); + + } + + public async Task GetPostListAsync(GetBlogPostsInput input) + { + // IQueryable + var postQuery = await _postRepository.GetQueryableAsync(); + + // 🔎 Arama + if (!input.Search.IsNullOrWhiteSpace()) + { + postQuery = postQuery.Where(p => + p.ContentTr.Contains(input.Search) || + p.ContentEn.Contains(input.Search)); + } + + // 📁 Kategori filtresi + if (input.CategoryId.HasValue) + { + postQuery = postQuery.Where(p => p.CategoryId == input.CategoryId.Value); + } + + // Toplam adet (sayfalama öncesi) + var totalCount = await AsyncExecuter.CountAsync(postQuery); + + // Sayfalama + sıralama + var pagedPosts = await AsyncExecuter.ToListAsync( + postQuery + .OrderByDescending(p => p.CreationTime) + .PageBy(input) + ); + + // Sayfadaki kategori kayıtları + var categoryIds = pagedPosts.Select(x => x.CategoryId).Distinct().ToList(); + var pageCategories = await _categoryRepository.GetListAsync(x => categoryIds.Contains(x.Id)); + var categoryDict = pageCategories.ToDictionary(x => x.Id, x => x); + + // Post DTO mapping + var postDtos = pagedPosts.Select(post => + { + var dto = ObjectMapper.Map(post); + if (categoryDict.TryGetValue(post.CategoryId, out var c)) + { + dto.Category = ObjectMapper.Map(c); + } + + dto.Author = new AuthorDto { Id = post.AuthorId, Name = "User" }; + return dto; + }).ToList(); + + // ----------- KATEGORİLER (PostCount ile) ----------- + var allCategories = await _categoryRepository.GetListAsync(); + + var allPostQuery = await _postRepository.GetQueryableAsync(); + var counts = await AsyncExecuter.ToListAsync( + allPostQuery + .Where(p => p.IsPublished) + .GroupBy(p => p.CategoryId) + .Select(g => new { g.Key, Count = g.Count() }) + ); + + var countDict = counts.ToDictionary(x => x.Key, x => x.Count); + + var categoryDtos = ObjectMapper.Map, List>(allCategories); + foreach (var dto in categoryDtos) + { + dto.PostCount = countDict.GetOrDefault(dto.Id); + } + + return new BlogPostAndCategoriesDto + { + Posts = new PagedResultDto(totalCount, postDtos), + Categories = categoryDtos + }; + } + + private async Task GetPostAsync(Guid id) + { + var post = await _postRepository.GetAsync(id); + var dto = ObjectMapper.Map(post); + + // Get category + dto.Category = ObjectMapper.Map( + await _categoryRepository.GetAsync(post.CategoryId) + ); + + // Get author info + dto.Author = new AuthorDto + { + Id = post.AuthorId, + Name = "User" + }; + + return dto; + } + + public async Task GetPostBySlugAsync(string slug) + { + var post = await _postRepository.FirstOrDefaultAsync(x => x.Slug == slug); + if (post == null) + { + throw new EntityNotFoundException(typeof(BlogPost)); + } + + return await GetPostAsync(post.Id); + } + + public async Task> GetProductListAsync() + { + var products = await _productRepository.GetListAsync(); + + return ObjectMapper.Map, List>(products.OrderBy(p => p.Order).ToList()); + } + + public async Task> GetPaymentMethodListAsync() + { + var paymentMethods = await _paymentMethodRepository.GetListAsync(); + + return ObjectMapper.Map, List>(paymentMethods); + } + + public async Task> GetInstallmentOptionListAsync() + { + var installmentOptions = await _installmentOptionRepository.GetListAsync(); + + return ObjectMapper.Map, List>(installmentOptions); + } + + public async Task CreateOrderAsync(OrderDto input) + { + var entity = new Order() + { + TenantId = input.Tenant.Id, + InstitutionName = input.Tenant.InstitutionName, + Founder = input.Tenant.Founder, + VknTckn = input.Tenant.VknTckn, + TaxOffice = input.Tenant.TaxOffice, + Address = input.Tenant.Address, + Address2 = input.Tenant.Address2, + District = input.Tenant.District, + Country = input.Tenant.Country, + City = input.Tenant.City, + PostalCode = input.Tenant.PostalCode, + Phone = input.Tenant.Phone, + Mobile = input.Tenant.Mobile, + Fax = input.Tenant.Fax, + Email = input.Tenant.Email, + Website = input.Tenant.Website, + + Subtotal = input.Subtotal, + Commission = input.Commission, + Total = input.Total, + PaymentMethod = input.PaymentMethod, + Installments = input.Installments, + InstallmentName = input.InstallmentName, + PaymentDataJson = JsonSerializer.Serialize(input.PaymentData), + }; + + foreach (var item in input.Items) + { + entity.Items.Add(new OrderItem + { + OrderId = entity.Id, + Order = entity, + ProductId = item.Product.Id, + ProductName = item.Product.Name, + BillingCycle = item.BillingCycle, + Quantity = item.Quantity, + TotalPrice = item.TotalPrice + }); + } + + await _orderRepository.InsertAsync(entity, autoSave: true); + + return new OrderDto + { + Id = entity.Id, + Total = entity.Total, + PaymentMethod = entity.PaymentMethod + }; + } +} diff --git a/api/src/Kurs.Platform.Application/Public/PublicAutoMapperProfile.cs b/api/src/Kurs.Platform.Application/Public/PublicAutoMapperProfile.cs new file mode 100644 index 00000000..b57c5afe --- /dev/null +++ b/api/src/Kurs.Platform.Application/Public/PublicAutoMapperProfile.cs @@ -0,0 +1,24 @@ +using AutoMapper; +using Kurs.Platform.Blog; +using Kurs.Platform.Demos; +using Kurs.Platform.Entities; +using Kurs.Platform.Orders; +using Kurs.Platform.Services; + +namespace Kurs.Platform.Public; + +public class PublicAutoMapperProfile : Profile +{ + public PublicAutoMapperProfile() + { + CreateMap().ReverseMap(); + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap().ReverseMap(); + CreateMap(); + CreateMap(); + CreateMap(); + } +} diff --git a/api/src/Kurs.Platform.Application/Services/ServiceAppService.cs b/api/src/Kurs.Platform.Application/Services/ServiceAppService.cs deleted file mode 100644 index bb61c541..00000000 --- a/api/src/Kurs.Platform.Application/Services/ServiceAppService.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Kurs.Platform.Entities; -using Kurs.Platform.Services; -using Volo.Abp.Domain.Repositories; - -namespace Kurs.Platform.Dashboard; - -public class ServiceAppService : PlatformAppService -{ - private readonly IRepository serviceRepository; - - public ServiceAppService( - IRepository serviceRepository) - { - this.serviceRepository = serviceRepository; - } - - public async Task> GetListAsync() - { - var entity = await serviceRepository.GetListAsync(); - - return ObjectMapper.Map, List>(entity); - } -} diff --git a/api/src/Kurs.Platform.Application/Services/ServiceAutoMapperProfile.cs b/api/src/Kurs.Platform.Application/Services/ServiceAutoMapperProfile.cs deleted file mode 100644 index 4e7302c8..00000000 --- a/api/src/Kurs.Platform.Application/Services/ServiceAutoMapperProfile.cs +++ /dev/null @@ -1,13 +0,0 @@ -using AutoMapper; -using Kurs.Platform.Entities; -using Kurs.Platform.Services; - -namespace Kurs.Platform; - -public class ServiceAutoMapperProfile : Profile -{ - public ServiceAutoMapperProfile() - { - CreateMap(); - } -} diff --git a/api/src/Kurs.Platform.Domain/Orders/Order.cs b/api/src/Kurs.Platform.Domain/Orders/Order.cs index b39da474..a4cc9f12 100644 --- a/api/src/Kurs.Platform.Domain/Orders/Order.cs +++ b/api/src/Kurs.Platform.Domain/Orders/Order.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities.Auditing; namespace Kurs.Platform.Orders; @@ -52,6 +51,6 @@ public class OrderItem : FullAuditedAggregateRoot public OrderItem() { - Id = Guid.NewGuid(); + Id = Guid.NewGuid(); } } diff --git a/ui/src/services/blog.service.ts b/ui/src/services/blog.service.ts index 9ec7d495..9125d4a8 100644 --- a/ui/src/services/blog.service.ts +++ b/ui/src/services/blog.service.ts @@ -11,7 +11,7 @@ import apiService from '@/services/api.service' class BlogService { async getPosts(params: BlogListParams = {}): Promise { const response = await apiService.fetchData({ - url: '/api/app/blog/post-list', + url: '/api/app/public/post-list', method: 'GET', params, }) @@ -20,15 +20,7 @@ class BlogService { async getPostBySlug(slug: string): Promise { const response = await apiService.fetchData({ - url: `/api/app/blog/post-by-slug?slug=${slug}`, - method: 'GET', - }) - return response.data - } - - async getPost(idOrSlug: string): Promise { - const response = await apiService.fetchData({ - url: `/api/app/blog/posts/${idOrSlug}`, + url: `/api/app/public/post-by-slug?slug=${slug}`, method: 'GET', }) return response.data @@ -75,14 +67,6 @@ class BlogService { return response.data } - // async getCategories(): Promise { - // const response = await apiService.fetchData({ - // url: '/api/app/blog/categories', - // method: 'GET', - // }) - // return response.data - // } - async deleteComment(id: string): Promise { await apiService.fetchData({ url: `/api/app/blog/comments/${id}`, diff --git a/ui/src/services/demo.service.ts b/ui/src/services/demo.service.ts index 62678d95..999dff7d 100644 --- a/ui/src/services/demo.service.ts +++ b/ui/src/services/demo.service.ts @@ -4,6 +4,6 @@ import apiService from './api.service' export const createDemoAsync = (input: DemoDto) => apiService.fetchData({ method: 'POST', - url: `/api/app/demo/demo`, + url: `/api/app/public/demo`, data: input as any, - }) \ No newline at end of file + }) diff --git a/ui/src/services/order.service.ts b/ui/src/services/order.service.ts index 03360f19..a4adf3c1 100644 --- a/ui/src/services/order.service.ts +++ b/ui/src/services/order.service.ts @@ -9,7 +9,7 @@ export class OrderService { apiService.fetchData( { method: 'GET', - url: '/api/app/order/product-list', + url: '/api/app/public/product-list', }, { apiName: this.apiName }, ) @@ -18,7 +18,7 @@ export class OrderService { apiService.fetchData( { method: 'GET', - url: '/api/app/order/payment-method-list', + url: '/api/app/public/payment-method-list', }, { apiName: this.apiName }, ) @@ -27,7 +27,7 @@ export class OrderService { apiService.fetchData( { method: 'GET', - url: '/api/app/order/installment-option-list', + url: '/api/app/public/installment-option-list', }, { apiName: this.apiName }, ) @@ -40,7 +40,7 @@ export class OrderService { const response = await apiService.fetchData<{ orderId?: string; id?: string }>( { method: 'POST', - url: `/api/app/order`, + url: `/api/app/public/order`, data: { tenant: orderData.tenant, items: orderData.items, diff --git a/ui/src/services/service.service.ts b/ui/src/services/service.service.ts index 07bb801c..58cc7811 100644 --- a/ui/src/services/service.service.ts +++ b/ui/src/services/service.service.ts @@ -5,7 +5,7 @@ export function getServices() { return apiService.fetchData( { method: 'GET', - url: '/api/app/service', + url: '/api/app/public/services-list', }, { apiName: 'Default' }, )