瀏覽代碼

兴唐黑白名单功能

tangjiang 1 周之前
父節點
當前提交
a72599d77e

+ 17 - 10
src/Hotline.Api/Controllers/CallNativeContrroller.cs

@@ -100,8 +100,9 @@ namespace Hotline.Api.Controllers
             {
                 WhiteBlackLog whiteBlackLog = new()
                 {
-                    LogType = "删除黑名单",
-                    LogContent = phone
+                    LogType = "1",
+                    LogAction = "删除",
+                    PhoneNum = phone
                 };
                 await _whiteBlackLogRepository.AddAsync(whiteBlackLog, HttpContext.RequestAborted);
             }
@@ -123,7 +124,7 @@ namespace Hotline.Api.Controllers
                 throw UserFriendlyException.SameMessage("有效期不能为空!");
 
             var isEx = await _db.Queryable<XingtangBlackPhone>().Where(p => p.StartPhone == dto.PhoneNum).AnyAsync();
-            if(isEx)
+            if (isEx)
                 throw UserFriendlyException.SameMessage("此号码已经是黑名单!");
 
             var id = await _db.Queryable<XingtangBlackPhone>().MaxAsync(p => p.BlackPhoneId);
@@ -142,8 +143,10 @@ namespace Hotline.Api.Controllers
             {
                 WhiteBlackLog whiteBlackLog = new()
                 {
-                    LogType = "新增黑名单",
-                    LogContent = dto.PhoneNum + "/" + dto.ValidDateTime
+                    LogType = "1",
+                    LogAction = "新增",
+                    PhoneNum = dto.PhoneNum,
+                    ValidDateTime = dto.ValidDateTime
                 };
                 await _whiteBlackLogRepository.AddAsync(whiteBlackLog, HttpContext.RequestAborted);
             }
@@ -180,8 +183,9 @@ namespace Hotline.Api.Controllers
             {
                 WhiteBlackLog whiteBlackLog = new()
                 {
-                    LogType = "删除白名单",
-                    LogContent = phone
+                    LogType = "2",
+                    LogAction = "删除",
+                    PhoneNum = phone
                 };
                 await _whiteBlackLogRepository.AddAsync(whiteBlackLog, HttpContext.RequestAborted);
             }
@@ -219,8 +223,10 @@ namespace Hotline.Api.Controllers
             {
                 WhiteBlackLog whiteBlackLog = new()
                 {
-                    LogType = "新增白名单",
-                    LogContent = dto.PhoneNum + "/" + dto.ValidDateTime
+                    LogType = "2",
+                    LogAction = "新增",
+                    PhoneNum = dto.PhoneNum,
+                    ValidDateTime = dto.ValidDateTime
                 };
                 await _whiteBlackLogRepository.AddAsync(whiteBlackLog, HttpContext.RequestAborted);
             }
@@ -239,8 +245,9 @@ namespace Hotline.Api.Controllers
                 .WhereIF(dto.StartTime.HasValue, p => p.CreationTime >= dto.StartTime)
                 .WhereIF(dto.EndTime.HasValue, p => p.CreationTime <= dto.EndTime)
                 .WhereIF(!string.IsNullOrEmpty(dto.LogType), p => p.LogType == dto.LogType)
+                .WhereIF(!string.IsNullOrEmpty(dto.LogAction), p => p.LogAction == dto.LogAction)
                 .WhereIF(!string.IsNullOrEmpty(dto.UserName), p => p.CreatorName == dto.UserName)
-                .WhereIF(!string.IsNullOrEmpty(dto.LogContent), p => p.LogContent.Contains(dto.LogContent))
+                .WhereIF(!string.IsNullOrEmpty(dto.PhoneNum), p => p.PhoneNum == dto.PhoneNum)
                 .ToPagedListAsync(dto, HttpContext.RequestAborted);
             return new PagedDto<WhiteBlackLog>(total, items);
         }

+ 2 - 0
src/Hotline.Share/Dtos/CallCenter/QueryCallsFixedDto.cs

@@ -69,6 +69,8 @@ namespace Hotline.Share.Dtos.CallCenter
         /// 1: 呼入
         /// 2: 呼出
         /// 3: 未接
+        /// 4:呼入白名单
+        /// 5:呼入黑名单
         /// </summary>
         public int Type { get; set; }
 

+ 9 - 4
src/Hotline.Share/Dtos/CallNative/BlackPhoneListQuery.cs

@@ -5,14 +5,19 @@ namespace Hotline.Share.Dtos.CallNative
     public record BlackPhoneListQuery : PagedKeywordRequest
     {
         /// <summary>
-        /// 操作类型
+        /// 操作类型 1:黑名单 2:白名单
         /// </summary>
-        public string? LogType { get; set; }
+        public string LogType { get; set; }
 
         /// <summary>
-        /// 操作数据
+        /// 操作动作
         /// </summary>
-        public string? LogContent { get; set; }
+        public string LogAction { get; set; }
+
+        /// <summary>
+        /// 操作号码
+        /// </summary>
+        public string PhoneNum { get; set; }
 
         /// <summary>
         /// 操作人

+ 15 - 4
src/Hotline/CallCenter/BlackLists/WhiteBlackLog.cs

@@ -11,15 +11,26 @@ namespace Hotline.CallCenter.BlackLists
     public class WhiteBlackLog : CreationEntity
     {
         /// <summary>
-        /// 操作类型
+        /// 操作类型 1:黑名单 2:白名单
         /// </summary>
         [SugarColumn(ColumnDescription = "操作类型", ColumnDataType = "varchar(50)")]
         public string LogType { get; set; }
 
         /// <summary>
-        /// 操作数据
+        /// 操作动作
         /// </summary>
-        [SugarColumn(ColumnDescription = "操作数据")]
-        public string LogContent { get; set; }
+        [SugarColumn(ColumnDescription = "操作类型", ColumnDataType = "varchar(50)")]
+        public string LogAction { get; set; }
+
+        /// <summary>
+        /// 操作号码
+        /// </summary>
+        [SugarColumn(ColumnDescription = "操作号码")]
+        public string PhoneNum { get; set; }
+
+        /// <summary>
+        /// 有效期
+        /// </summary>
+        public DateTime? ValidDateTime { get; set; }
     }
 }