✨新增手机短信验证码管理
This commit is contained in:
parent
df36de52fa
commit
baf3630847
@ -0,0 +1,77 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Model.Dto;
|
||||
using ZR.ServiceCore.Services;
|
||||
|
||||
//创建时间:2023-11-19
|
||||
namespace ZR.Admin.WebApi.Controllers.System.monitor
|
||||
{
|
||||
/// <summary>
|
||||
/// 短信验证码记录
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("system/SmscodeLog")]
|
||||
[ApiExplorerSettings(GroupName = "sys")]
|
||||
public class SmsCodeLogController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
/// 短信验证码记录接口
|
||||
/// </summary>
|
||||
private readonly ISmsCodeLogService _SmscodeLogService;
|
||||
|
||||
public SmsCodeLogController(ISmsCodeLogService SmscodeLogService)
|
||||
{
|
||||
_SmscodeLogService = SmscodeLogService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询短信验证码记录列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("list")]
|
||||
[ActionPermissionFilter(Permission = "smscodelog:list")]
|
||||
public IActionResult QuerySmscodeLog([FromQuery] SmscodeLogQueryDto parm)
|
||||
{
|
||||
var response = _SmscodeLogService.GetList(parm);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除短信验证码记录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{ids}")]
|
||||
[ActionPermissionFilter(Permission = "smscodelog:delete")]
|
||||
[Log(Title = "短信验证码记录", BusinessType = BusinessType.DELETE)]
|
||||
public IActionResult DeleteSmscodeLog(string ids)
|
||||
{
|
||||
long[] idsArr = Tools.SpitLongArrary(ids);
|
||||
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||
|
||||
var response = _SmscodeLogService.Delete(idsArr);
|
||||
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出短信验证码记录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Log(Title = "短信验证码记录", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
|
||||
[HttpGet("export")]
|
||||
[ActionPermissionFilter(Permission = "smscodelog:export")]
|
||||
public IActionResult Export([FromQuery] SmscodeLogQueryDto parm)
|
||||
{
|
||||
parm.PageNum = 1;
|
||||
parm.PageSize = 100000;
|
||||
var list = _SmscodeLogService.GetList(parm).Result;
|
||||
if (list == null || list.Count <= 0)
|
||||
{
|
||||
return ToResponse(ResultCode.FAIL, "没有要导出的数据");
|
||||
}
|
||||
var result = ExportExcelMini(list, "短信验证码记录", "短信验证码记录");
|
||||
return ExportExcel(result.Item2, result.Item1);
|
||||
}
|
||||
}
|
||||
}
|
||||
61
ZR.ServiceCore/Model/Dto/SmsCodeLogDto.cs
Normal file
61
ZR.ServiceCore/Model/Dto/SmsCodeLogDto.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using MiniExcelLibs.Attributes;
|
||||
|
||||
namespace ZR.Model.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 短信验证码记录查询对象
|
||||
/// </summary>
|
||||
public class SmscodeLogQueryDto : PagerInfo
|
||||
{
|
||||
public int? Userid { get; set; }
|
||||
public long? PhoneNum { get; set; }
|
||||
public DateTime? BeginAddTime { get; set; }
|
||||
public DateTime? EndAddTime { get; set; }
|
||||
public int? SendType { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 短信验证码记录输入输出对象
|
||||
/// </summary>
|
||||
public class SmsCodeLogDto
|
||||
{
|
||||
[Required(ErrorMessage = "Id不能为空")]
|
||||
[ExcelColumn(Name = "Id")]
|
||||
[ExcelColumnName("Id")]
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long Id { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "短信验证码")]
|
||||
[ExcelColumnName("短信验证码")]
|
||||
public string SmsCode { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "用户id")]
|
||||
[ExcelColumnName("用户id")]
|
||||
public int? Userid { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "手机号")]
|
||||
[ExcelColumnName("手机号")]
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long? PhoneNum { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "短信内容")]
|
||||
[ExcelColumnName("短信内容")]
|
||||
public string SmsContent { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "添加时间", Format = "yyyy-MM-dd HH:mm:ss")]
|
||||
[ExcelColumnName("添加时间")]
|
||||
public DateTime? AddTime { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "用户IP")]
|
||||
[ExcelColumnName("用户IP")]
|
||||
public string UserIP { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "发送类型")]
|
||||
[ExcelColumnName("发送类型")]
|
||||
public int? SendType { get; set; }
|
||||
[ExcelColumn(Name = "地理位置")]
|
||||
[ExcelColumnName("地理位置")]
|
||||
public string Location { get; set; }
|
||||
}
|
||||
}
|
||||
45
ZR.ServiceCore/Model/SmsCodeLog.cs
Normal file
45
ZR.ServiceCore/Model/SmsCodeLog.cs
Normal file
@ -0,0 +1,45 @@
|
||||
namespace ZR.ServiceCore.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// 短信验证码记录
|
||||
/// </summary>
|
||||
[SugarTable("smsCode_log")]
|
||||
public class SmsCodeLog
|
||||
{
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 短信验证码
|
||||
/// </summary>
|
||||
public string SmsCode { get; set; }
|
||||
/// <summary>
|
||||
/// 用户id
|
||||
/// </summary>
|
||||
public long Userid { get; set; }
|
||||
/// <summary>
|
||||
/// 手机号
|
||||
/// </summary>
|
||||
public long PhoneNum { get; set; }
|
||||
/// <summary>
|
||||
/// 短信内容
|
||||
/// </summary>
|
||||
public string SmsContent { get; set; }
|
||||
/// <summary>
|
||||
/// 发送时间
|
||||
/// </summary>
|
||||
public DateTime AddTime { get; set; }
|
||||
/// <summary>
|
||||
/// 用户IP
|
||||
/// </summary>
|
||||
public string UserIP { get; set; }
|
||||
/// <summary>
|
||||
/// 地理位置
|
||||
/// </summary>
|
||||
public string Location { get; set; }
|
||||
/// <summary>
|
||||
/// 1、登录 2、注册 3、找回密码
|
||||
/// </summary>
|
||||
public int SendType { get; set; }
|
||||
}
|
||||
}
|
||||
20
ZR.ServiceCore/Services/IService/ISmsCodeLogService.cs
Normal file
20
ZR.ServiceCore/Services/IService/ISmsCodeLogService.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using ZR.Model;
|
||||
using ZR.Model.Dto;
|
||||
using ZR.Service;
|
||||
using ZR.ServiceCore.Model;
|
||||
|
||||
namespace ZR.ServiceCore.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 短信验证码记录service接口
|
||||
/// </summary>
|
||||
public interface ISmsCodeLogService : IBaseService<SmsCodeLog>
|
||||
{
|
||||
PagedInfo<SmsCodeLogDto> GetList(SmscodeLogQueryDto parm);
|
||||
|
||||
SmsCodeLog GetInfo(long Id);
|
||||
|
||||
SmsCodeLog AddSmscodeLog(SmsCodeLog parm);
|
||||
|
||||
}
|
||||
}
|
||||
65
ZR.ServiceCore/Services/SmsCodeLogService.cs
Normal file
65
ZR.ServiceCore/Services/SmsCodeLogService.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using Infrastructure.Attribute;
|
||||
using ZR.Model;
|
||||
using ZR.Model.Dto;
|
||||
using ZR.Repository;
|
||||
using ZR.Service;
|
||||
using ZR.ServiceCore.Model;
|
||||
|
||||
namespace ZR.ServiceCore.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 短信验证码记录Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISmsCodeLogService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SmsCodeLogService : BaseService<SmsCodeLog>, ISmsCodeLogService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询短信验证码记录列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<SmsCodeLogDto> GetList(SmscodeLogQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<SmsCodeLog>();
|
||||
|
||||
predicate = predicate.AndIF(parm.Userid != null, it => it.Userid == parm.Userid);
|
||||
predicate = predicate.AndIF(parm.PhoneNum != null, it => it.PhoneNum == parm.PhoneNum);
|
||||
predicate = predicate.AndIF(parm.BeginAddTime == null, it => it.AddTime >= DateTime.Now.ToShortDateString().ParseToDateTime());
|
||||
predicate = predicate.AndIF(parm.BeginAddTime != null, it => it.AddTime >= parm.BeginAddTime);
|
||||
predicate = predicate.AndIF(parm.EndAddTime != null, it => it.AddTime <= parm.EndAddTime);
|
||||
predicate = predicate.AndIF(parm.SendType != null, it => it.SendType == parm.SendType);
|
||||
var response = Queryable()
|
||||
//.OrderBy("Id desc")
|
||||
.Where(predicate.ToExpression())
|
||||
.ToPage<SmsCodeLog, SmsCodeLogDto>(parm);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
public SmsCodeLog GetInfo(long Id)
|
||||
{
|
||||
var response = Queryable()
|
||||
.Where(x => x.Id == Id)
|
||||
.First();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加短信验证码记录
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public SmsCodeLog AddSmscodeLog(SmsCodeLog model)
|
||||
{
|
||||
model.Id = Context.Insertable(model).ExecuteReturnSnowflakeId();
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -50,6 +50,7 @@ namespace ZR.ServiceCore.SqlSugar
|
||||
db.CodeFirst.InitTables(typeof(SysDictType));
|
||||
db.CodeFirst.InitTables(typeof(SqlDiffLog));
|
||||
db.CodeFirst.InitTables(typeof(EmailTpl));
|
||||
db.CodeFirst.InitTables(typeof(SmsCodeLog));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user