|  | @@ -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
 | 
	
		
			
				|  |  |      }
 |