From 63edb33bf5c61bc12269b2e6049b404deeca3423 Mon Sep 17 00:00:00 2001 From: SamSys Date: Wed, 7 Jan 2026 14:49:44 +0330 Subject: [PATCH] Sms Report Init --- .../SmsResultAgg/ISmsResultRepository.cs | 16 +++++++- .../SmsResult/Dto/SmsReportDto.cs | 13 +++++++ .../SmsResult/Dto/SmsReportSearchModel.cs | 38 +++++++++++++++++++ .../SmsResult/ISmsResultApplication.cs | 16 +++++++- .../SmsResultApplication.cs | 14 +++++++ .../Repository/SmsResultRepository.cs | 28 +++++++++++++- .../Admin/Controllers/SmsReportController.cs | 24 ++++++++++++ ServiceHost/Properties/launchSettings.json | 2 +- 8 files changed, 145 insertions(+), 6 deletions(-) create mode 100644 CompanyManagment.App.Contracts/SmsResult/Dto/SmsReportDto.cs create mode 100644 CompanyManagment.App.Contracts/SmsResult/Dto/SmsReportSearchModel.cs create mode 100644 ServiceHost/Areas/Admin/Controllers/SmsReportController.cs diff --git a/Company.Domain/SmsResultAgg/ISmsResultRepository.cs b/Company.Domain/SmsResultAgg/ISmsResultRepository.cs index ce631aa5..1dac4376 100644 --- a/Company.Domain/SmsResultAgg/ISmsResultRepository.cs +++ b/Company.Domain/SmsResultAgg/ISmsResultRepository.cs @@ -1,10 +1,22 @@ -using CompanyManagment.App.Contracts.SmsResult; +using _0_Framework.Domain; +using CompanyManagment.App.Contracts.SmsResult; +using CompanyManagment.App.Contracts.SmsResult.Dto; using System.Collections.Generic; -using _0_Framework.Domain; +using System.Threading.Tasks; namespace Company.Domain.SmsResultAgg; public interface ISmsResultRepository : IRepository { + #region ForApi + + /// + /// دریافت لیست پیامکها + /// + /// + /// + Task> GetSmsReportList(SmsReportSearchModel command); + + #endregion List Search(SmsResultSearchModel searchModel); } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/SmsResult/Dto/SmsReportDto.cs b/CompanyManagment.App.Contracts/SmsResult/Dto/SmsReportDto.cs new file mode 100644 index 00000000..9158d59d --- /dev/null +++ b/CompanyManagment.App.Contracts/SmsResult/Dto/SmsReportDto.cs @@ -0,0 +1,13 @@ +namespace CompanyManagment.App.Contracts.SmsResult.Dto; + +public class SmsReportDto +{ + /// + /// تاریخ ارسال + /// + public string SentDate { get; set; } + + +} + + diff --git a/CompanyManagment.App.Contracts/SmsResult/Dto/SmsReportSearchModel.cs b/CompanyManagment.App.Contracts/SmsResult/Dto/SmsReportSearchModel.cs new file mode 100644 index 00000000..a386d47e --- /dev/null +++ b/CompanyManagment.App.Contracts/SmsResult/Dto/SmsReportSearchModel.cs @@ -0,0 +1,38 @@ +using _0_Framework.Application.Enums; + +namespace CompanyManagment.App.Contracts.SmsResult.Dto; + +public class SmsReportSearchModel +{ + //نوع پیامک + public TypeOfSmsSetting TypeOfSms { get; set; } + + /// + /// شماره موبایل + /// + public string Mobile { get; set; } + + /// + /// آی دی طرف حساب + /// + public long ContractingPatyId { get; set; } + + /// + /// سال + /// + public string Year { get; set; } + /// + /// ماه + /// + public string Month { get; set; } + + /// + /// تاریخ شروع + /// + public string StartDateFa { get; set; } + + /// + /// تاریخ پایان + /// + public string EndDateFa { get; set; } +} \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/SmsResult/ISmsResultApplication.cs b/CompanyManagment.App.Contracts/SmsResult/ISmsResultApplication.cs index 8d8a9b52..786716c3 100644 --- a/CompanyManagment.App.Contracts/SmsResult/ISmsResultApplication.cs +++ b/CompanyManagment.App.Contracts/SmsResult/ISmsResultApplication.cs @@ -1,14 +1,26 @@ -using System; +using _0_Framework.Application; +using CompanyManagment.App.Contracts.SmsResult.Dto; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using _0_Framework.Application; namespace CompanyManagment.App.Contracts.SmsResult; public interface ISmsResultApplication { + #region ForApi + + /// + /// دریافت لیست پیامکها + /// + /// + /// + Task> GetSmsReportList(SmsReportSearchModel command); + + #endregion + OperationResult Create(CreateSmsResult command); List Search(SmsResultSearchModel searchModel); } \ No newline at end of file diff --git a/CompanyManagment.Application/SmsResultApplication.cs b/CompanyManagment.Application/SmsResultApplication.cs index 03f01b29..abf9b4f4 100644 --- a/CompanyManagment.Application/SmsResultApplication.cs +++ b/CompanyManagment.Application/SmsResultApplication.cs @@ -1,8 +1,10 @@ using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using _0_Framework.Application; using Company.Domain.SmsResultAgg; using CompanyManagment.App.Contracts.SmsResult; +using CompanyManagment.App.Contracts.SmsResult.Dto; namespace CompanyManagment.Application; @@ -15,6 +17,18 @@ public class SmsResultApplication : ISmsResultApplication _smsResultRepository = smsResultRepository; } + + #region ForApi + + public async Task> GetSmsReportList(SmsReportSearchModel command) + { + return await _smsResultRepository.GetSmsReportList(command); + } + + #endregion + + + public OperationResult Create(CreateSmsResult command) { var op = new OperationResult(); diff --git a/CompanyManagment.EFCore/Repository/SmsResultRepository.cs b/CompanyManagment.EFCore/Repository/SmsResultRepository.cs index 0b555a7a..496d6085 100644 --- a/CompanyManagment.EFCore/Repository/SmsResultRepository.cs +++ b/CompanyManagment.EFCore/Repository/SmsResultRepository.cs @@ -1,9 +1,14 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; using System.Linq; +using System.Threading.Tasks; using _0_Framework.Application; using _0_Framework.InfraStructure; using Company.Domain.SmsResultAgg; using CompanyManagment.App.Contracts.SmsResult; +using CompanyManagment.App.Contracts.SmsResult.Dto; +using Microsoft.EntityFrameworkCore; namespace CompanyManagment.EFCore.Repository; @@ -15,6 +20,27 @@ public class SmsResultRepository : RepositoryBase , ISmsResultR _context = context; } + #region ForApi + + public async Task> GetSmsReportList(SmsReportSearchModel command) + { + var watch = new Stopwatch(); + watch.Start(); + var res = _context.SmsResults.GroupBy(x => x.CreationDate); + Console.WriteLine("query : " + watch.Elapsed); + watch.Stop(); + watch.Reset(); + watch.Start(); + var b = await res.Take(9000).Select(x => new SmsReportDto() + { + SentDate = x.Key.ToFarsi() + }).ToListAsync(); + Console.WriteLine("ToList : " + watch.Elapsed); + return b; + } + + #endregion + public List Search(SmsResultSearchModel searchModel) { diff --git a/ServiceHost/Areas/Admin/Controllers/SmsReportController.cs b/ServiceHost/Areas/Admin/Controllers/SmsReportController.cs new file mode 100644 index 00000000..da294057 --- /dev/null +++ b/ServiceHost/Areas/Admin/Controllers/SmsReportController.cs @@ -0,0 +1,24 @@ +using CompanyManagment.App.Contracts.SmsResult; +using CompanyManagment.App.Contracts.SmsResult.Dto; +using Microsoft.AspNetCore.Mvc; +using ServiceHost.BaseControllers; + +namespace ServiceHost.Areas.Admin.Controllers; + +public class SmsReportController : AdminBaseController +{ + private readonly ISmsResultApplication _smsResultApplication; + + public SmsReportController(ISmsResultApplication smsResultApplication) + { + _smsResultApplication = smsResultApplication; + } + + [HttpGet] + public async Task> GetSmsReportList() + { + var search = new SmsReportSearchModel(); + var result =await _smsResultApplication.GetSmsReportList(search); + return result; + } +} \ No newline at end of file diff --git a/ServiceHost/Properties/launchSettings.json b/ServiceHost/Properties/launchSettings.json index f5214c2b..29cf7c0a 100644 --- a/ServiceHost/Properties/launchSettings.json +++ b/ServiceHost/Properties/launchSettings.json @@ -19,7 +19,7 @@ "sqlDebugging": true, "dotnetRunMessages": "true", "nativeDebugging": true, - "applicationUrl": "https://localhost:5004;http://localhost:5003;https://192.168.0.117:5006", + "applicationUrl": "https://localhost:5004;http://localhost:5003;", "jsWebView2Debugging": false, "hotReloadEnabled": true },