浏览代码

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

leiy 2 年之前
父节点
当前提交
17826a6814

+ 170 - 21
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -1,9 +1,4 @@
-
-
-using Google.Protobuf.WellKnownTypes;
-using OASystem.Domain.Dtos.UserDto;
-using OASystem.Infrastructure.Repositories.System;
-using System.ComponentModel.Design;
+using System.Collections;
 
 namespace OASystem.API.Controllers
 {
@@ -23,11 +18,16 @@ 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;
         private readonly JobPostRepository _jobRep;
 
-        public SystemController( CompanyRepository syscom,DepartmentRepository sysDepRep, UsersRepository userRep,
+        public SystemController( CompanyRepository syscom, DepartmentRepository sysDepRep, UsersRepository userRep,
             IMapper mapper, SetDataRepository setDataRepository, CompanyRepository companyRepository,
-            SystemMenuPermissionRepository systemMenuPermissionRepository, JobPostRepository jobRep)
+            SystemMenuPermissionRepository systemMenuPermissionRepository, PageFunctionPermissionRepository pageFunctionPermissionRepository,
+            SystemMenuAndFunctionRepository systemMenuAndFunctionRepository, JobPostAuthorityRepository jobPostAuthorityRepository, JobPostRepository jobRep)
+            
         {
             _syscomRep = syscom;
             _sysDepRep = sysDepRep;
@@ -36,7 +36,9 @@ namespace OASystem.API.Controllers
             _setDataRepository = setDataRepository;
             _CompanyRepository = companyRepository;
             _SystemMenuPermissionRepository = systemMenuPermissionRepository;
-            _jobRep = jobRep;
+            _PageFunctionPermissionRepository = pageFunctionPermissionRepository;
+            _SystemMenuAndFunctionRepository = systemMenuAndFunctionRepository;
+            _JobPostAuthorityRepository = jobPostAuthorityRepository;
         }
 
         #region 企业操作
@@ -58,8 +60,16 @@ namespace OASystem.API.Controllers
                     {
                         return Ok(JsonView(CompanyDataResult.Msg));
                     }
+                    List<CompanyView> companyListView = _mapper.Map<List<CompanyView>>(CompanyDataResult.Data);
+                    for (int i = 0; i < companyListView.Count; i++)
+                    {
+                        if (companyListView[i].ParentCompanyId != 0)
+                        {
+                            companyListView[i].ParentCompanyName = companyListView.Find(x => x.Id == companyListView[i].ParentCompanyId).CompanyName;
+                        }
 
-                    return Ok(JsonView(true, "查询成功!", CompanyDataResult.Data));
+                    }
+                    return Ok(JsonView(true, "查询成功!", companyListView));
                 }
                 else if (dto.PortType == 2)
                 {
@@ -212,7 +222,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)
                 {
@@ -364,7 +379,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)
                 {
@@ -519,6 +539,10 @@ namespace OASystem.API.Controllers
                 {
                     sqlWhere += string.Format(@" And su.DepId={0}", dto.DepId);
                 }
+                if (dto.JobPostId != 0)
+                {
+                    sqlWhere += string.Format(@" And su.JobPostId={0}", dto.JobPostId);
+                }
                 if (!string.IsNullOrEmpty(sqlWhere.Trim()))
                 {
                     Regex r = new Regex("And");
@@ -656,18 +680,42 @@ 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,
+                    selList = new string[0]
+                }) ;
             }
 
             //公司数据
@@ -683,11 +731,112 @@ namespace OASystem.API.Controllers
             {
                 setDataResult = setDataResult.Data,
                 CompanyDataResult = CompanyDataResult.Data,
-                SystemMenuPermissionData = SystemMenuPermissionData.Data
+                SystemMenuPermissionData = viewData,
+                PageOperation = PageOperation,
             };
 
             return Ok(JsonView(200, "成功!", Dyresult));
         }
+        /// <summary>
+        /// 获取职务权限
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public IActionResult QueryJobAuth(QueryJobAuthDto dto)
+        {
+            //选中的操作权限
+            var DBdata = _JobPostAuthorityRepository.QueryDto<Sys_JobPostAuthority, JobPostAuthorityView>(x=>x.JpId == dto.jobid).ToList();
+            var SystemMenuPermissionData = _SystemMenuPermissionRepository.QueryDto<Sys_SystemMenuPermission, SystemMenuPermissionView>(x => x.Mid == dto.moduleId).ToList();
+            if (SystemMenuPermissionData == null || SystemMenuPermissionData.Count() == 0)
+            {
+                return Ok(JsonView("暂无数据"));
+            }
+
+            //所有操作
+            var PageOperation = _PageFunctionPermissionRepository.QueryDto<Sys_PageFunctionPermission, Sys_PageFunctionPermission>().ToList();
+
+            //获取所有关联页面
+            var Sys_SystemMenuAndFunction = _SystemMenuAndFunctionRepository.QueryDto<Sys_SystemMenuAndFunction, SystemMenuAndFunctionView>().ToList();
+
+            ArrayList viewData = new ArrayList();
+            //组合页面数据
+            foreach (var item in SystemMenuPermissionData)
+            {
+                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);
+                    }
+                }
+
+                //获取本职务的页面拥有的权限
+                var DBwhere =  DBdata.Where(x => x.SmId == item.Id && x.JpId == dto.jobid).ToList();
+
+                viewData.Add(new
+                {
+                    Id = item.Id,
+                    Mid = item.Mid,
+                    Name = item.Name,
+                    SystemMenuCode = item.SystemMenuCode,
+                    opList = ids,
+                    selList = DBwhere.Select(x => x.FId)
+                }) ;
+            }
+
+            return Ok(JsonView(200, "成功!", viewData));
+        }
+        /// <summary>
+        /// 保存岗位权限
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> SaveJobAuth(SaveJobDto dto)
+        {
+            //获取所有关联页面
+            var Sys_SystemMenuAndFunction = _SystemMenuAndFunctionRepository.QueryDto<Sys_SystemMenuAndFunction, SystemMenuAndFunctionView>().ToList();
+            
+            List<Sys_JobPostAuthority> adds = new List<Sys_JobPostAuthority>();
+            foreach (var item in dto.Savejobs)
+            {
+                foreach (var fid in item.FIds)
+                {
+                    var whereobj = Sys_SystemMenuAndFunction.FirstOrDefault(x => x.FId == fid && x.SmId == item.SmId);
+                    if (whereobj != null)
+                    {
+                        adds.Add(new Sys_JobPostAuthority
+                        {
+                            CreateTime = DateTime.Now,
+                            CreateUserId = 245,
+                            FId = fid,
+                            JpId = dto.Jpid,
+                            SmId = item.SmId
+                        });
+                    }
+                }
+            }
+
+            _JobPostAuthorityRepository.BeginTran();
+            try
+            {
+                bool isdel = await _JobPostAuthorityRepository.DeleteAsync<Sys_JobPostAuthority>(x => x.JpId == dto.Jpid);
+                int UpRows = _JobPostAuthorityRepository.Adds<Sys_JobPostAuthority>(adds);
+            }
+            catch (Exception ex)
+            {
+                _JobPostAuthorityRepository.RollbackTran();
+                return Ok(JsonView("系统错误!"));
+            }
+
+            _JobPostAuthorityRepository.CommitTran();
+            return Ok(JsonView(200, "成功", new { }));
+        }
 
         #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>

+ 15 - 0
OASystem/OASystem.Domain/Dtos/System/QueryJobAuthDto.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.System
+{
+    public class QueryJobAuthDto
+    {
+        public int jobid { get; set; }
+
+        public int moduleId { get; set; }
+    }
+}

+ 20 - 0
OASystem/OASystem.Domain/Dtos/System/SaveJobDto.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.System
+{
+    public class SaveJobDto
+    {
+        public int Jpid { get; set; }
+        public List<savejob> Savejobs { get; set; }
+    }
+
+    public class savejob
+    {
+        public int SmId { get; set; }
+        public List<int> FIds { get; set; }
+    }
+}

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

@@ -20,6 +20,11 @@ namespace OASystem.Domain.Dtos.System
         /// 部门Id
         /// </summary>
         public int DepId { get;set; }
+
+        /// <summary>
+        /// 岗位Id
+        /// </summary>
+        public int JobPostId { get; set; }
     }
     /// <summary>
     /// 修改用户信息

+ 6 - 7
OASystem/OASystem.Domain/Entities/System/Sys_Company.cs

@@ -4,19 +4,19 @@
     /// 公司表
     /// </summary>
     [SugarTable("Sys_Company")]
-    public class Sys_Company: EntityBase
+    public class Sys_Company : EntityBase
     {
         /// <summary>
         /// 公司Code
         /// </summary>
-        [SugarColumn(IsNullable =true,ColumnDataType ="varchar(20)")]
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(20)")]
         public string CompanyCode { get; set; }
         /// <summary>
         /// 公司名称
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
         public string CompanyName { get; set; }
-       
+
         /// <summary>
         /// 公司所在地
         /// </summary>
@@ -25,19 +25,18 @@
         /// <summary>
         /// 负责人Id
         /// </summary>
-        [SugarColumn(IsNullable =true, ColumnDataType = "int")]
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
         public int ContactUserId { get; set; }
         /// <summary>
         /// 联系方式
         /// </summary>
-        [SugarColumn(IsNullable =true, ColumnDataType = "varchar(30)")]
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(30)")]
         public string Tel { get; set; }
         /// <summary>
         /// 父级公司Id
         /// </summary>
-        [SugarColumn(IsNullable =true, ColumnDataType = "int")]
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
         public int ParentCompanyId { get; set; }
     }
 
-    
 }

+ 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

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

@@ -10,7 +10,7 @@ namespace OASystem.Domain.Entities.System
     /// 系统用户权限设置(个人级)
     /// </summary>
     [SugarTable("Sys_UserAuthority")]
-    public class Sys_UserAuthority
+    public class Sys_UserAuthority:EntityBase
     {
         /// <summary>
         /// 用户Id

+ 21 - 1
OASystem/OASystem.Domain/ViewModels/CompanyView.cs

@@ -1,4 +1,5 @@
 using OASystem.Domain.Entities.System;
+using System.Text.RegularExpressions;
 
 namespace OASystem.Domain.ViewModels
 {
@@ -8,7 +9,7 @@ namespace OASystem.Domain.ViewModels
     public class CompanyView
     {
         /// <summary>
-        /// 公司id
+        /// 公司Id
         /// </summary>
         public int Id { get; set; }
         /// <summary>
@@ -19,9 +20,28 @@ namespace OASystem.Domain.ViewModels
         /// 公司名称
         /// </summary>
         public string CompanyName { get; set; }
+
+        /// <summary>
+        /// 公司所在地
+        /// </summary>
+        public string Address { get; set; }
+        /// <summary>
+        /// 负责人Id
+        /// </summary>
+        public int ContactUserId { get; set; }
+        /// <summary>
+        /// 联系方式
+        /// </summary>
+        public string Tel { get; set; }
+        
         /// <summary>
         /// 父级公司Id
         /// </summary>
         public int ParentCompanyId { get; set; }
+        /// <summary>
+        /// 父级公司Name
+        /// </summary>
+        public string ParentCompanyName { get; set; }
     }
+
 }

+ 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; }
 
+
+
     }
 }

+ 5 - 1
OASystem/OASystem.Infrastructure/Repositories/BaseRepository.cs

@@ -183,11 +183,15 @@ 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();
         }
-        public virtual int AddsAsync<T>(List<T> entity) where T : EntityBase, new()
+        public virtual int Adds<T>(List<T> entity) where T : EntityBase, new()
         {
             return _sqlSugar.Insertable<T>(entity).ExecuteCommand();
         }

+ 1 - 7
OASystem/OASystem.Infrastructure/Repositories/System/CompanyRepository.cs

@@ -30,13 +30,7 @@ namespace OASystem.Infrastructure.Repositories.System
 
             result.Code = 0;
             result.Msg = "成功!";
-            result.Data = DBdata.Select(x=> new CompanyView
-            {
-                CompanyCode = x.CompanyCode,
-                CompanyName = x.CompanyName,
-                Id = x.Id,
-                ParentCompanyId = x.ParentCompanyId
-            });
+            result.Data = DBdata;
             return result;
         }
 

+ 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)
+        {
+        }
+    }
+}