Browse Source

完善权限接口

yuanrf 2 years ago
parent
commit
408be7b898

+ 63 - 13
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -1,6 +1,7 @@
 
 
 using OASystem.Infrastructure.Repositories.System;
+using System.Collections;
 
 namespace OASystem.API.Controllers
 {
@@ -20,10 +21,14 @@ namespace OASystem.API.Controllers
         private readonly SetDataRepository _setDataRepository;
         private readonly SystemMenuPermissionRepository _SystemMenuPermissionRepository;
         private readonly CompanyRepository _CompanyRepository;
+        private readonly PageFunctionPermissionRepository _PageFunctionPermissionRepository;
+        private readonly SystemMenuAndFunctionRepository _SystemMenuAndFunctionRepository;
+        private readonly JobPostAuthorityRepository _JobPostAuthorityRepository;
 
-        public SystemController( CompanyRepository syscom,DepartmentRepository sysDepRep, UsersRepository userRep,
+        public SystemController( CompanyRepository syscom, DepartmentRepository sysDepRep, UsersRepository userRep,
             IMapper mapper, SetDataRepository setDataRepository, CompanyRepository companyRepository,
-            SystemMenuPermissionRepository systemMenuPermissionRepository)
+            SystemMenuPermissionRepository systemMenuPermissionRepository, PageFunctionPermissionRepository pageFunctionPermissionRepository,
+            SystemMenuAndFunctionRepository systemMenuAndFunctionRepository, JobPostAuthorityRepository jobPostAuthorityRepository)
         {
             _syscomRep = syscom;
             _sysDepRep = sysDepRep;
@@ -32,6 +37,9 @@ namespace OASystem.API.Controllers
             _setDataRepository = setDataRepository;
             _CompanyRepository = companyRepository;
             _SystemMenuPermissionRepository = systemMenuPermissionRepository;
+            _PageFunctionPermissionRepository = pageFunctionPermissionRepository;
+            _SystemMenuAndFunctionRepository = systemMenuAndFunctionRepository;
+            _JobPostAuthorityRepository = jobPostAuthorityRepository;
         }
 
         #region user 操作
@@ -230,7 +238,12 @@ namespace OASystem.API.Controllers
             {
                 if (dto.PortType==1)
                 {
-                    return Ok(JsonView(false, "暂无数据!"));
+                    var result = _sysDepRep.QueryDto<Sys_Department, DepartmentIView>(s => s.CompanyId == dto.CompanyId).ToList();
+                    if (result.Count == 0)
+                    {
+                        return Ok(JsonView(false, "暂无数据!"));
+                    }
+                    return Ok(JsonView(true, "查询成功!", result));
                 }
                 else if (dto.PortType==2)
                 {
@@ -382,7 +395,12 @@ namespace OASystem.API.Controllers
             {
                 if (dto.PortType == 1)
                 {
-                    return Ok(JsonView(false, "暂无数据!"));
+                    var result = _sysDepRep.QueryDto<Sys_JobPost, JobPostView>(s => s.CompanyId == dto.CompanyId && s.DepId == dto.DepId).ToList();
+                    if (result.Count == 0)
+                    {
+                        return Ok(JsonView(false, "暂无数据!"));
+                    }
+                    return Ok(JsonView(true, "查询成功!", result));
                 }
                 else if (dto.PortType == 2)
                 {
@@ -480,18 +498,41 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(setDataResult.Msg));
             }
 
-            List<SetDataView> setDataList = _mapper.Map<List<SetDataView>>(setDataResult.Data);
-            var mod = setDataList.Find(x => x.Name == "权限模块");
-            if (mod == null)
+            //操作方式
+            var PageOperation = _PageFunctionPermissionRepository.QueryDto<Sys_PageFunctionPermission, Sys_PageFunctionPermission>().ToList();
+
+            //获取所有关联页面
+            var Sys_SystemMenuAndFunction = _SystemMenuAndFunctionRepository.QueryDto<Sys_SystemMenuAndFunction, SystemMenuAndFunctionView>().ToList();
+
+
+            //页面数据
+            var SystemMenuPermissionData = _SystemMenuPermissionRepository.QueryDto<Sys_SystemMenuPermission, SystemMenuPermissionView>(x=>x.Mid == dto.moduleId).ToList();
+            if (SystemMenuPermissionData == null || SystemMenuPermissionData.Count() == 0)
             {
-                return Ok(JsonView("未找到权限模块!"));
+                return Ok(JsonView("暂无数据"));
             }
 
-            //页面数据
-            var SystemMenuPermissionData = _SystemMenuPermissionRepository.GetSystemMenuViweData(_SystemMenuPermissionRepository, mod.Id, dto.pageSize, dto.currentPage);
-            if (SystemMenuPermissionData.Code != 0)
+            ArrayList viewData = new ArrayList();
+            //组合页面数据
+            foreach (var item in SystemMenuPermissionData)
             {
-                return Ok(JsonView(SystemMenuPermissionData.Msg));
+                ArrayList ids = new ArrayList();
+                foreach (var viewop in PageOperation)
+                {
+                    var op =  Sys_SystemMenuAndFunction.FirstOrDefault(x => x.SmId == item.Id && x.FId == viewop.Id);
+                    if (op != null)
+                    {
+                        ids.Add(viewop.Id);
+                    }
+                }
+                viewData.Add(new
+                {
+                    Id = item.Id,
+                    Mid = item.Mid,
+                    Name = item.Name,
+                    SystemMenuCode = item.SystemMenuCode,
+                    opList = ids
+                });
             }
 
             //公司数据
@@ -507,12 +548,21 @@ namespace OASystem.API.Controllers
             {
                 setDataResult = setDataResult.Data,
                 CompanyDataResult = CompanyDataResult.Data,
-                SystemMenuPermissionData = SystemMenuPermissionData.Data
+                SystemMenuPermissionData = viewData,
+                PageOperation = PageOperation,
             };
 
             return Ok(JsonView(200, "成功!", Dyresult));
         }
 
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public IActionResult QueryJobAuto(int jobid)
+        {
+           var DBdata = _JobPostAuthorityRepository.QueryDto<Sys_JobPostAuthority, JobPostAuthorityView>(x=>x.JpId == jobid).ToList();
+            return Ok(JsonView(200, "成功!", DBdata));
+        }
+
         #endregion
     }
 }

+ 5 - 0
OASystem/OASystem.Domain/Dtos/System/AuthDto.cs

@@ -8,6 +8,11 @@ namespace OASystem.Domain.Dtos.System
 {
     public class AuthDto
     {
+        /// <summary>
+        /// 模块id
+        /// </summary>
+        public int moduleId { get; set; }
+
         /// <summary>
         /// 显示的行数
         /// </summary>

+ 1 - 1
OASystem/OASystem.Domain/Entities/System/Sys_JobPostAuthority.cs

@@ -10,7 +10,7 @@ namespace OASystem.Domain.Entities.System
     /// 岗位权限设置
     /// </summary>
     [SugarTable("Sys_JobPostAuthority")]
-    public class Sys_JobPostAuthority
+    public class Sys_JobPostAuthority: EntityBase
     {
         /// <summary>
         /// 岗位表Id

+ 24 - 0
OASystem/OASystem.Domain/ViewModels/System/JobPostAuthorityView.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.System
+{
+    public class JobPostAuthorityView
+    {
+        /// <summary>
+        /// 岗位表Id
+        /// </summary>
+        public int JpId { get; set; }
+        /// <summary>
+        /// 页面权限Id
+        /// </summary>
+        public int SmId { get; set; }
+        /// <summary>
+        /// 页面功能Id
+        /// </summary>
+        public int FId { get; set; }
+    }
+}

+ 25 - 0
OASystem/OASystem.Domain/ViewModels/System/PageFunctionPermissionView.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.System
+{
+    public class PageFunctionPermissionView
+    {
+        /// <summary>
+        /// 功能名称
+        /// </summary>
+        public string FunctionName { get; set; }
+        /// <summary>
+        /// 功能权限Code
+        /// </summary>
+        public string FunctionCode { get; set; }
+        /// <summary>
+        /// 是否启用0否1是
+        /// </summary>
+        public int IsEnable { get; set; }
+
+    }
+}

+ 20 - 0
OASystem/OASystem.Domain/ViewModels/System/SystemMenuAndFunctionView.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.System
+{
+    public class SystemMenuAndFunctionView
+    {
+        /// <summary>
+        /// 页面id
+        /// </summary>
+        public int SmId { get; set; }
+        /// <summary>
+        /// 功能Id
+        /// </summary>
+        public int FId { get; set; }
+    }
+}

+ 2 - 0
OASystem/OASystem.Domain/ViewModels/System/SystemMenuPermissionView.cs

@@ -23,5 +23,7 @@ namespace OASystem.Domain.ViewModels.System
         /// </summary>
         public int Mid { get; set; }
 
+
+
     }
 }

+ 4 - 0
OASystem/OASystem.Infrastructure/Repositories/BaseRepository.cs

@@ -183,6 +183,10 @@ namespace OASystem.Infrastructure.Repositories
         {
             return _sqlSugar.Queryable<T>().Where(a => a.IsDel < 1).Where(exp).Select<Dto>();
         }
+        public virtual ISugarQueryable<Dto> QueryDto<T, Dto>() where T : EntityBase, new()
+        {
+            return _sqlSugar.Queryable<T>().Where(a => a.IsDel < 1).Select<Dto>();
+        }
         public virtual Task<int> AddAsync<T>(T entity) where T : EntityBase, new()
         {
             return _sqlSugar.Insertable(entity).ExecuteCommandAsync();

+ 13 - 0
OASystem/OASystem.Infrastructure/Repositories/System/JobPostAuthorityRepository.cs

@@ -0,0 +1,13 @@
+using OASystem.Domain;
+using OASystem.Domain.Dtos.System;
+using OASystem.Domain.Dtos.UserDto;
+
+namespace OASystem.Infrastructure.Repositories.System
+{
+    public class JobPostAuthorityRepository: BaseRepository<Sys_JobPostAuthority, JobPostAuthorityView>
+    {
+        public JobPostAuthorityRepository(SqlSugarClient sqlSugar) : base(sqlSugar)
+        {
+        }
+    }
+}

+ 10 - 0
OASystem/OASystem.Infrastructure/Repositories/System/PageFunctionPermissionRepository.cs

@@ -0,0 +1,10 @@
+namespace OASystem.Infrastructure.Repositories.System
+{
+    public class PageFunctionPermissionRepository : BaseRepository<Sys_PageFunctionPermission, PageFunctionPermissionView>
+    {
+        public PageFunctionPermissionRepository(SqlSugarClient sqlSugar) : base(sqlSugar)
+        {
+        }
+
+    }
+}

+ 15 - 0
OASystem/OASystem.Infrastructure/Repositories/System/SystemMenuAndFunctionRepository.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Infrastructure.Repositories.System
+{
+    public class SystemMenuAndFunctionRepository : BaseRepository<Sys_SystemMenuAndFunction, SystemMenuAndFunctionView>
+    {
+        public SystemMenuAndFunctionRepository(SqlSugarClient sqlSugar) : base(sqlSugar)
+        {
+        }
+    }
+}