Explorar el Código

增加字典库的删除,以及组织的删除接口

tangjiang hace 3 meses
padre
commit
59ef37d18c

+ 22 - 1
src/Hotline.Api/Controllers/OrgController.cs

@@ -1,4 +1,6 @@
-using Hotline.Configurations;
+using Hotline.Api.Filter;
+using Hotline.Caching.Interfaces;
+using Hotline.Configurations;
 using Hotline.Permissions;
 using Hotline.Settings;
 using Hotline.Share.Dtos.Org;
@@ -154,6 +156,25 @@ namespace Hotline.Api.Controllers
             await _systemOrganizeRepository.UpdateAsync(org, HttpContext.RequestAborted);
         }
 
+        /// <summary>
+        /// 删除组织数据
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        [HttpDelete("delete-org/{id}")]
+        [LogFilter("删除组织")]
+        public async Task DeleteOrg(string id)
+        {
+            var org = await _systemOrganizeRepository.GetAsync(id, HttpContext.RequestAborted);
+            if (org is null)
+                throw UserFriendlyException.SameMessage("无效组织架构");
+           var chail= await _systemOrganizeRepository.AnyAsync(p => p.ParentId == org.Id);
+            if(chail==true)
+                throw UserFriendlyException.SameMessage("存在下级部门,请先删除下级部门数据!");
+
+            await _systemOrganizeRepository.RemoveAsync(org, true, HttpContext.RequestAborted);
+        }
+
         /// <summary>
         /// 获取组织
         /// </summary>

+ 19 - 0
src/Hotline.Api/Controllers/SysController.cs

@@ -1,4 +1,5 @@
 using EasyCaching.Core;
+using Hotline.Api.Filter;
 using Hotline.Application.Systems;
 using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Ivrs;
@@ -355,6 +356,24 @@ namespace Hotline.Api.Controllers
             await _sysDicDataRepository.UpdateAsync(dicData, HttpContext.RequestAborted);
         }
 
+        /// <summary>
+        /// 删除字典数据
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        [HttpDelete("delete-dicdata/{id}")]
+        [LogFilter("删除字典")]
+        public async Task DeleteDicData(string id)
+        {
+            var dicData = await _sysDicDataRepository.GetAsync(id, HttpContext.RequestAborted);
+            if (dicData is null)
+                throw UserFriendlyException.SameMessage("无效字典数据");
+            var dicType = await _sysDicTypeRepository.GetAsync(dicData.DicTypeId, HttpContext.RequestAborted);
+            if (dicType != null)
+                _systemDicDataCacheManager.RemoveSysDicDataCache(dicType.DicTypeCode);
+            await _sysDicDataRepository.RemoveAsync(dicData, true, HttpContext.RequestAborted);
+        }
+
         #endregion
 
         #region 行政区划