Эх сурвалжийг харах

Merge branch 'master' of http://git.fwt.com/Hotline/hotline

xf 2 жил өмнө
parent
commit
ae3e4705d4

+ 12 - 2
src/Hotline.Api/Controllers/CommonPController.cs

@@ -13,11 +13,13 @@ namespace Hotline.Api.Controllers
     public class CommonPController: BaseController
     {
         private readonly ICommonOpinionDomainService _commonOpinionDomainService;
+        private readonly ISystemAreaDomainService _systemAreaDomainService;
         private readonly IMapper _mapper;
 
-        public CommonPController(ICommonOpinionDomainService commonOpinionDomainService,IMapper mapper)
+        public CommonPController(ICommonOpinionDomainService commonOpinionDomainService,ISystemAreaDomainService systemAreaDomainService, IMapper mapper)
         {
             _commonOpinionDomainService = commonOpinionDomainService;
+            _systemAreaDomainService= systemAreaDomainService;
             _mapper = mapper;
         }
 
@@ -54,6 +56,14 @@ namespace Hotline.Api.Controllers
             await _commonOpinionDomainService.DelCommonOpinion(dto.Ids, HttpContext.RequestAborted);
         }
 
-
+        /// <summary>
+        /// 获取省市区树形
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("tree-area")]
+        public async Task<List<SystemArea>> GetAearTree()
+        {
+            return await _systemAreaDomainService.GetAreaTree();
+        }
     }
 }

+ 1 - 1
src/Hotline.Api/appsettings.Development.json

@@ -94,7 +94,7 @@
     }
   },
   "DatabaseConfiguration": {
-    "ApplyDbMigrations": false,
+    "ApplyDbMigrations": true,
     "ApplySeed": false
   }
 }

+ 14 - 0
src/Hotline.Repository.SqlSugar/System/SystemAreaRepository.cs

@@ -0,0 +1,14 @@
+using Hotline.Repository.SqlSugar.DataPermissions;
+using Hotline.Settings;
+using SqlSugar;
+using XF.Domain.Dependency;
+
+namespace Hotline.Repository.SqlSugar.System
+{
+    public class SystemAreaRepository : BaseRepository<SystemArea>, ISystemAreaRepository, IScopeDependency
+    {
+        public SystemAreaRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder) : base(uow, dataPermissionFilterBuilder)
+        {
+        }
+    }
+}

+ 8 - 0
src/Hotline/Settings/ISystemAreaDomainService.cs

@@ -0,0 +1,8 @@
+
+namespace Hotline.Settings
+{
+    public interface ISystemAreaDomainService
+    {
+        Task<List<SystemArea>> GetAreaTree();
+    }
+}

+ 8 - 0
src/Hotline/Settings/ISystemAreaRepository.cs

@@ -0,0 +1,8 @@
+using XF.Domain.Repository;
+
+namespace Hotline.Settings
+{
+    public interface ISystemAreaRepository: IRepository<SystemArea>
+    {
+    }
+}

+ 5 - 6
src/Hotline/Settings/SystemArea.cs

@@ -1,14 +1,9 @@
 using SqlSugar;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using XF.Domain.Repository;
 
 namespace Hotline.Settings
 {
-    public class SystemArea:Entity
+    public class SystemArea: CreationEntity
     {
         /// <summary>
         /// 区域名称
@@ -25,5 +20,9 @@ namespace Hotline.Settings
         /// 简称
         /// </summary>
         public string AreaNameAbbreviation { get; set; }
+
+
+        [SugarColumn(IsIgnore = true)]
+        public List<SystemArea> Children { get; set; }
     }
 }

+ 19 - 0
src/Hotline/Settings/SystemAreaDomainService.cs

@@ -0,0 +1,19 @@
+using XF.Domain.Dependency;
+
+namespace Hotline.Settings
+{
+    public class SystemAreaDomainService : ISystemAreaDomainService, IScopeDependency
+    {
+        private readonly ISystemAreaRepository _systemAreaRepository;
+
+        public SystemAreaDomainService(ISystemAreaRepository systemAreaRepository)
+        {
+            _systemAreaRepository = systemAreaRepository;
+        }
+
+        public async Task<List<SystemArea>> GetAreaTree()
+        {
+           return await  _systemAreaRepository.Queryable().ToTreeAsync(x => x.Children,q=>q.ParentId, "");
+        }
+    }
+}