Explorar o código

泸州新增行业管理

tangjiang hai 2 meses
pai
achega
c19aa1d616

+ 38 - 0
src/Hotline.Api/Controllers/IndustrialManagementController.cs

@@ -11,7 +11,9 @@ using Hotline.Share.Dtos.Order;
 using Hotline.Share.Requests;
 using Hotline.Tools;
 using MapsterMapper;
+using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
+using NPOI.POIFS.Properties;
 using SqlSugar;
 using XF.Domain.Authentications;
 using XF.Domain.Exceptions;
@@ -19,6 +21,9 @@ using XF.Domain.Repository;
 
 namespace Hotline.Api.Controllers
 {
+    /// <summary>
+    /// 行业管理
+    /// </summary>
     public class IndustrialManagementController : BaseController
     {
         private readonly IMapper _mapper;
@@ -49,6 +54,27 @@ namespace Hotline.Api.Controllers
             _industryClassificationApplication = industryClassificationApplication;
         }
 
+        /// <summary>
+        /// 获取部门
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("getorglist")]
+        public async Task<List<IndustrialOrgs>> GetOrgList()
+        {
+            var list = await _systemOrganizeRepository.Queryable()
+                     .Select(p => new IndustrialOrgs
+                     {
+                         OrgId = p.Id,
+                         OrgName = p.Name,
+                         ParentId = p.ParentId,
+                         ParentName = p.ParentId,
+                         IsDisable = SqlFunc.Subqueryable<IndustryAssociations>().Where(d => d.OrganizeId == p.Id).Any()
+                     })
+                     .ToTreeAsync(d => d.Children, it => it.ParentId, null);
+
+            return list;
+        }
+
         /// <summary>
         /// 新增行业
         /// </summary>
@@ -69,6 +95,12 @@ namespace Hotline.Api.Controllers
             if (isHas)
                 throw UserFriendlyException.SameMessage("存在此行业名称");
 
+            var hasDat = await _industrialManagementRepository.Queryable()
+                    .Includes(d => d.Orgs)
+                    .AnyAsync(d => d.Orgs.Any(p => dto.OrgsIds.Contains(p.Id)));
+            if (hasDat)
+                throw UserFriendlyException.SameMessage("部门已关联行业!");
+
             IndustrialManagement industrialManagement = new()
             {
                 IndustrialName = dto.IndustryName,
@@ -100,6 +132,12 @@ namespace Hotline.Api.Controllers
             if (isHas)
                 throw UserFriendlyException.SameMessage("存在此行业名称");
 
+            var hasDat = await _industrialManagementRepository.Queryable()
+                .Includes(d => d.Orgs)
+                .AnyAsync(d => d.Id != dto.Id && d.Orgs.Any(p => dto.OrgsIds.Contains(p.Id)));
+            if (hasDat)
+                throw UserFriendlyException.SameMessage("部门已关联行业!");
+
             var data = await _industrialManagementRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted);
             if (data == null)
                 throw UserFriendlyException.SameMessage("数据查询失败");

+ 6 - 1
src/Hotline.Share/Dtos/IndustryClassification/IndustryAddDto.cs

@@ -71,7 +71,7 @@ namespace Hotline.Share.Dtos.IndustryClassification
         /// 行业ID
         /// </summary>
         public string Id { get; set; }
-        
+
         /// <summary>
         /// 行业名称
         /// </summary>
@@ -88,6 +88,9 @@ namespace Hotline.Share.Dtos.IndustryClassification
         public DateTime? UpdateTime { get; set; }
     }
 
+    /// <summary>
+    /// 行业工单返回参数
+    /// </summary>
     public class IndustrialManagementOrderDto
     {
         /// <summary>
@@ -301,4 +304,6 @@ namespace Hotline.Share.Dtos.IndustryClassification
         /// </summary>
         public string? ActualHandleOrgName { get; set; }
     }
+
+    
 }

+ 38 - 0
src/Hotline/IndustryClassification/IndustrialOrgs.cs

@@ -0,0 +1,38 @@
+using SqlSugar;
+
+namespace Hotline.IndustryClassification
+{
+    /// <summary>
+    /// 关联部门
+    /// </summary>
+    public class IndustrialOrgs
+    {
+        /// <summary>
+        /// 部门Id
+        /// </summary>
+        [SugarColumn(IsTreeKey = true)]
+        public string OrgId { get; set; }
+
+        /// <summary>
+        /// 部门名称
+        /// </summary>
+        public string OrgName { get; set; }
+
+        /// <summary>
+        /// 上级ID
+        /// </summary>
+        public string ParentId { get; set; }
+
+        /// <summary>
+        /// 上级名称
+        /// </summary>
+        public string? ParentName { get; set; }
+
+        /// <summary>
+        /// 是否启用
+        /// </summary>
+        public bool IsDisable { get; set; }
+
+        public List<IndustrialOrgs> Children { get; set; }
+    }
+}