From 4f06e1eba4530ef3b87f53f7d7340d8a80322192 Mon Sep 17 00:00:00 2001
From: wxd <123@qq.com>
Date: Wed, 27 Mar 2024 09:40:19 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E4=BB=BB=E5=8A=A1=E5=89=8D?=
=?UTF-8?q?=E5=A4=87=E4=BB=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../SmsTasks/CreateSmsTaskDto.cs | 86 ++++++++++++
.../SmsTasks/SmsTaskDto.cs | 88 ++++++++++++
.../SmsTasks/UpdateSmsTaskDto.cs | 86 ++++++++++++
.../SmsTasks/SmsTaskAppService.cs | 131 ++++++++++++++++++
.../SmsTypeAppService.cs} | 0
.../SmsHttpApiHostModule.cs | 1 +
6 files changed, 392 insertions(+)
create mode 100644 src/Shentun.Sms.Application.Contracts/SmsTasks/CreateSmsTaskDto.cs
create mode 100644 src/Shentun.Sms.Application.Contracts/SmsTasks/SmsTaskDto.cs
create mode 100644 src/Shentun.Sms.Application.Contracts/SmsTasks/UpdateSmsTaskDto.cs
create mode 100644 src/Shentun.Sms.Application/SmsTasks/SmsTaskAppService.cs
rename src/Shentun.Sms.Application/{SendTypes/SendTypeAppService.cs => SmsTypes/SmsTypeAppService.cs} (100%)
diff --git a/src/Shentun.Sms.Application.Contracts/SmsTasks/CreateSmsTaskDto.cs b/src/Shentun.Sms.Application.Contracts/SmsTasks/CreateSmsTaskDto.cs
new file mode 100644
index 0000000..0834822
--- /dev/null
+++ b/src/Shentun.Sms.Application.Contracts/SmsTasks/CreateSmsTaskDto.cs
@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.Sms.SmsTasks
+{
+ public class CreateSmsTaskDto
+ {
+ ///
+ /// 短信类别ID
+ ///
+ public Guid SmsTypeId { get; set; }
+
+ ///
+ /// 人员ID
+ ///
+ public string PersonId { get; set; }
+
+ ///
+ /// 姓名
+ ///
+ public string PersonName { get; set; }
+
+ ///
+ /// 手机号国家代码
+ ///
+ public string CountryCode { get; set; }
+
+ ///
+ /// 手机号
+ ///
+ public string MobileTelephone { get; set; }
+
+ ///
+ /// 短信内容
+ ///
+ public string Content { get; set; }
+
+
+ ///
+ /// 应用ID
+ ///
+ public Guid SmsAppId { get; set; }
+
+
+ ///
+ /// 第三方系统唯一ID
+ ///
+ public string? ThirdId { get; set; }
+
+
+
+ ///
+ /// 任务周期类别
+ ///
+ public char TaskCycleType { get; set; }
+
+
+ ///
+ /// 任务表达式
+ ///
+ public string? TaskCorn { get; set; }
+
+
+ ///
+ /// 停止执行时间
+ ///
+ public DateTime? StopTime { get; set; }
+
+
+ ///
+ /// 是否启用
+ ///
+ public char IsActive { get; set; }
+
+ ///
+ /// 发送者用户ID
+ ///
+ public string? SenderId { get; set; }
+
+ ///
+ /// 发送者用户名
+ ///
+ public string? SenderName { get; set; }
+ }
+}
diff --git a/src/Shentun.Sms.Application.Contracts/SmsTasks/SmsTaskDto.cs b/src/Shentun.Sms.Application.Contracts/SmsTasks/SmsTaskDto.cs
new file mode 100644
index 0000000..b253f13
--- /dev/null
+++ b/src/Shentun.Sms.Application.Contracts/SmsTasks/SmsTaskDto.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using System.Text;
+
+namespace Shentun.Sms.SmsTasks
+{
+ public class SmsTaskDto : AuditedEntityGuidDtoName
+ {
+ ///
+ /// 短信类别ID
+ ///
+ public Guid SmsTypeId { get; set; }
+
+ ///
+ /// 人员ID
+ ///
+ public string PersonId { get; set; }
+
+ ///
+ /// 姓名
+ ///
+ public string PersonName { get; set; }
+
+ ///
+ /// 手机号国家代码
+ ///
+ public string CountryCode { get; set; }
+
+ ///
+ /// 手机号
+ ///
+ public string MobileTelephone { get; set; }
+
+ ///
+ /// 短信内容
+ ///
+ public string Content { get; set; }
+
+
+ ///
+ /// 应用ID
+ ///
+ public Guid SmsAppId { get; set; }
+
+
+ ///
+ /// 第三方系统唯一ID
+ ///
+ public string? ThirdId { get; set; }
+
+
+
+ ///
+ /// 任务周期类别
+ ///
+ public char TaskCycleType { get; set; }
+
+
+ ///
+ /// 任务表达式
+ ///
+ public string? TaskCorn { get; set; }
+
+
+ ///
+ /// 停止执行时间
+ ///
+ public DateTime? StopTime { get; set; }
+
+
+ ///
+ /// 是否启用
+ ///
+ public char IsActive { get; set; }
+
+ ///
+ /// 发送者用户ID
+ ///
+ public string? SenderId { get; set; }
+
+ ///
+ /// 发送者用户名
+ ///
+ public string? SenderName { get; set; }
+ }
+}
diff --git a/src/Shentun.Sms.Application.Contracts/SmsTasks/UpdateSmsTaskDto.cs b/src/Shentun.Sms.Application.Contracts/SmsTasks/UpdateSmsTaskDto.cs
new file mode 100644
index 0000000..7393b4c
--- /dev/null
+++ b/src/Shentun.Sms.Application.Contracts/SmsTasks/UpdateSmsTaskDto.cs
@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.Sms.SmsTasks
+{
+ public class UpdateSmsTaskDto
+ {
+ ///
+ /// 短信类别ID
+ ///
+ public Guid SmsTypeId { get; set; }
+
+ ///
+ /// 人员ID
+ ///
+ public string PersonId { get; set; }
+
+ ///
+ /// 姓名
+ ///
+ public string PersonName { get; set; }
+
+ ///
+ /// 手机号国家代码
+ ///
+ public string CountryCode { get; set; }
+
+ ///
+ /// 手机号
+ ///
+ public string MobileTelephone { get; set; }
+
+ ///
+ /// 短信内容
+ ///
+ public string Content { get; set; }
+
+
+ ///
+ /// 应用ID
+ ///
+ public Guid SmsAppId { get; set; }
+
+
+ ///
+ /// 第三方系统唯一ID
+ ///
+ public string? ThirdId { get; set; }
+
+
+
+ ///
+ /// 任务周期类别
+ ///
+ public char TaskCycleType { get; set; }
+
+
+ ///
+ /// 任务表达式
+ ///
+ public string? TaskCorn { get; set; }
+
+
+ ///
+ /// 停止执行时间
+ ///
+ public DateTime? StopTime { get; set; }
+
+
+ ///
+ /// 是否启用
+ ///
+ public char IsActive { get; set; }
+
+ ///
+ /// 发送者用户ID
+ ///
+ public string? SenderId { get; set; }
+
+ ///
+ /// 发送者用户名
+ ///
+ public string? SenderName { get; set; }
+ }
+}
diff --git a/src/Shentun.Sms.Application/SmsTasks/SmsTaskAppService.cs b/src/Shentun.Sms.Application/SmsTasks/SmsTaskAppService.cs
new file mode 100644
index 0000000..98ee4c8
--- /dev/null
+++ b/src/Shentun.Sms.Application/SmsTasks/SmsTaskAppService.cs
@@ -0,0 +1,131 @@
+using Microsoft.AspNetCore.Mvc;
+using Shentun.Sms.SmsTasks;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Volo.Abp.Application.Services;
+using Volo.Abp.Domain.Repositories;
+using Volo.Abp.Identity;
+
+namespace Shentun.Sms.SmsTasks
+{
+ ///
+ /// 短信任务计划
+ ///
+ public class SmsTaskAppService : ApplicationService
+ {
+ private readonly IRepository _smsTaskRepository;
+ private readonly IRepository _userRepository;
+ private readonly SmsTaskManager _smsTaskManager;
+
+ public SmsTaskAppService(
+ SmsTaskManager smsTaskManager,
+ IRepository smsTaskRepository,
+ IRepository userRepository
+ )
+ {
+ _smsTaskManager = smsTaskManager;
+ _smsTaskRepository = smsTaskRepository;
+ _userRepository = userRepository;
+ }
+
+ ///
+ /// 获取应用对象
+ ///
+ ///
+ ///
+ [HttpGet("api/app/sms_task/get")]
+ public async Task GetAsync(Guid id)
+ {
+ var userList = await _userRepository.GetListAsync();
+ var entity = await _smsTaskRepository.GetAsync(id);
+ var entityDto = ObjectMapper.Map(entity);
+ entityDto.CreatorName = EntityHelper.GetUserName(userList, entityDto.CreatorId.Value);
+ entityDto.LastModifierName = EntityHelper.GetUserName(userList, entityDto.LastModifierId.Value);
+ return entityDto;
+ }
+
+
+
+
+ ///
+ /// 创建
+ ///
+ ///
+ [HttpPost("api/app/sms_task/create")]
+ public async Task CreateAsync(CreateSmsTaskDto input)
+ {
+ DataHelper.CheckEntityIsNull(input, "", "参数有误");
+
+ var entity = new SmsTask(GuidGenerator.Create())
+ {
+ Content = input.Content,
+ CountryCode = input.CountryCode,
+ IsActive = input.IsActive,
+ MobileTelephone = input.MobileTelephone,
+ PersonId = input.PersonId,
+ PersonName = input.PersonName,
+ SenderId = input.SenderId,
+ SenderName = input.SenderName,
+ SmsAppId = input.SmsAppId,
+ SmsTypeId = input.SmsTypeId,
+ StopTime = input.StopTime,
+ TaskCorn = input.TaskCorn,
+ TaskCycleType = input.TaskCycleType,
+ ThirdId = input.ThirdId
+ };
+
+ entity = _smsTaskManager.CreateAsync(entity);
+
+ await _smsTaskRepository.InsertAsync(entity);
+
+ }
+
+ ///
+ /// 修改
+ ///
+ ///
+ [HttpPost("api/app/sms_task/update")]
+ public async Task UpdateAsync(Guid id, UpdateSmsTaskDto input)
+ {
+ DataHelper.CheckEntityIsNull(input, "", "参数有误");
+
+ var entity = await _smsTaskRepository.GetAsync(id);
+ var sourceEntity = new SmsTask(GuidGenerator.Create())
+ {
+ Content = input.Content,
+ CountryCode = input.CountryCode,
+ IsActive = input.IsActive,
+ MobileTelephone = input.MobileTelephone,
+ PersonId = input.PersonId,
+ PersonName = input.PersonName,
+ SenderId = input.SenderId,
+ SenderName = input.SenderName,
+ SmsAppId = input.SmsAppId,
+ SmsTypeId = input.SmsTypeId,
+ StopTime = input.StopTime,
+ TaskCorn = input.TaskCorn,
+ TaskCycleType = input.TaskCycleType,
+ ThirdId = input.ThirdId
+ };
+
+ _smsTaskManager.UpdateAsync(sourceEntity, entity);
+
+ await _smsTaskRepository.UpdateAsync(entity);
+
+
+ }
+
+ ///
+ /// 删除
+ ///
+ ///
+ [HttpPost("api/app/sms_task/delete")]
+ public async Task DeleteAsync(Guid id)
+ {
+ await _smsTaskManager.CheckIsDeleteAsync(id);
+ }
+ }
+}
diff --git a/src/Shentun.Sms.Application/SendTypes/SendTypeAppService.cs b/src/Shentun.Sms.Application/SmsTypes/SmsTypeAppService.cs
similarity index 100%
rename from src/Shentun.Sms.Application/SendTypes/SendTypeAppService.cs
rename to src/Shentun.Sms.Application/SmsTypes/SmsTypeAppService.cs
diff --git a/src/Shentun.Sms.HttpApi.Host/SmsHttpApiHostModule.cs b/src/Shentun.Sms.HttpApi.Host/SmsHttpApiHostModule.cs
index 7a07926..45de524 100644
--- a/src/Shentun.Sms.HttpApi.Host/SmsHttpApiHostModule.cs
+++ b/src/Shentun.Sms.HttpApi.Host/SmsHttpApiHostModule.cs
@@ -165,6 +165,7 @@ public class SmsHttpApiHostModule : AbpModule
private void ConfigureConventionalControllers()
{
+ //自动api
Configure(options =>
{
options.ConventionalControllers.Create(typeof(SmsApplicationModule).Assembly);