wangh лет назад: 2
Родитель
Сommit
14a5b8134a

+ 64 - 20
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 企业操作
@@ -212,7 +214,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 +371,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)
                 {
@@ -655,18 +667,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
+                });
             }
 
             //公司数据
@@ -682,12 +717,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
     }
 }

+ 9 - 2
OASystem/OASystem.Api/OASystemAuthentication.cs

@@ -1,6 +1,13 @@
-namespace OASystem.API
+using Microsoft.AspNetCore.Mvc.Filters;
+using Microsoft.IdentityModel.Tokens;
+using System.IdentityModel.Tokens.Jwt;
+using IAuthorizationFilter = Microsoft.AspNetCore.Mvc.Filters.IAuthorizationFilter;
+
+namespace OASystem.API
 {
-    public class OASystemAuthentication
+    public class OASystemAuthentication : AuthorizeAttribute
     {
+
+
     }
 }

+ 22 - 4
OASystem/OASystem.Api/Program.cs

@@ -1,9 +1,13 @@
 
 using StackExchange.Redis;
 using Autofac.Core;
+using OASystem.API;
+using OASystem.RedisRepository.RedisAsyncHelper;
+using OASystem.RedisRepository.Config;
 
 var builder = WebApplication.CreateBuilder(args);
 var basePath = AppContext.BaseDirectory;
+
 //引入配置文件
 var _config = new ConfigurationBuilder()
                  .SetBasePath(basePath)
@@ -14,11 +18,21 @@ builder.Services.AddSingleton(new AppSettingsHelper(_config));
 // Add services to the container.
 builder.Services.AddControllersWithViews();
 
-#region redis
+#region Cors
+
+builder.Services.AddCors(policy =>
+{
+    policy.AddPolicy("Cors", opt => opt
+    .AllowAnyOrigin()
+    .AllowAnyHeader()
+    .AllowAnyMethod()
+    .WithExposedHeaders("X-Pagination"));
+});
 
 #endregion
 
 
+
 #region 接口分组
 var groups = new List<Tuple<string, string>>
 {
@@ -124,6 +138,8 @@ if (AppSettingsHelper.Get("UseSwagger").ToBool())
 #endregion
 
 #region 添加校验
+
+//builder.Services.AddTransient<OASystemAuthentication>();
 builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options =>
 {
     options.TokenValidationParameters = new TokenValidationParameters
@@ -135,6 +151,8 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJw
         ValidAudience = "OASystem.com",
         ValidIssuer = "OASystem.com",
         IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["JwtSecurityKey"])),
+        ClockSkew = TimeSpan.FromSeconds(30), //过期时间容错值,解决服务器端时间不同步问题(秒)
+        RequireExpirationTime = true,
     };
 });
 #endregion
@@ -198,9 +216,9 @@ if (!app.Environment.IsDevelopment())
 app.UseStaticFiles();
 
 app.UseRouting();
-app.UseAuthentication();
-app.UseAuthorization();
-
+app.UseAuthentication(); // 认证
+app.UseAuthorization();  // 授权
+app.UseCors("Cors");  //Cors
 
 #region 启用swaggerUI
 if (AppSettingsHelper.Get("UseSwagger").ToBool())

+ 1 - 1
OASystem/OASystem.Api/appsettings.json

@@ -3,6 +3,6 @@
     "OA2023DB": "server=132.232.92.186;uid=sa;pwd=Yjx@158291;database=OA2023DB;"
   },
   "JwtSecurityKey": "48d3f4fe770940a1068052f581536b81", //jwt密钥
-  "UseSwagger": "true", //启用Swagger
+  "UseSwagger": "true" //启用Swagger
 
 }

+ 2 - 2
OASystem/OASystem.Domain/AutoMappers/_baseMappingProfile.cs

@@ -24,8 +24,8 @@ namespace OASystem.Domain.AutoMappers
 
             #region 部门板块
             CreateMap<Sys_Department, DepartmentIView>();
-            CreateMap<AddDepartmentDto,Sys_Department>();
-            CreateMap<EditDepartmentDto,Sys_Department>();
+            CreateMap<AddDepartmentDto, Sys_Department>();
+            CreateMap<EditDepartmentDto, Sys_Department>();
             #endregion
 
             #region 岗位板块

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

+ 4 - 1
OASystem/OASystem.Domain/Entities/Groups/Grp_DeleClientNeeds.cs

@@ -29,8 +29,11 @@ namespace OASystem.Domain.Entities.Groups
         public string HotelAddress { get; set; }
         /// <summary>
         /// 酒店星级
+        /// 一星 二星级 三星 四星  
+        /// 普通五星 精品五星 奢华五星 豪华五星
+        /// 多个 普通五星|豪华五星
         /// </summary>
-        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(20)")]
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(100)")]
         public string HotelStarRank { get; set; }
         /// <summary>
         /// 酒店其他需求

+ 10 - 9
OASystem/OASystem.Domain/Entities/Groups/Grp_DelegationInfo.cs

@@ -7,7 +7,7 @@ using System.Threading.Tasks;
 namespace OASystem.Domain.Entities.Groups
 {
     /// <summary>
-    /// 团组表
+    /// 团组信息
     /// </summary>
     [SugarTable("Grp_DelegationInfo")]
     public class Grp_DelegationInfo:EntityBase
@@ -65,7 +65,7 @@ namespace OASystem.Domain.Entities.Groups
         /// <summary>
         /// 出访国家
         /// </summary>
-        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(100)")]
         public string VisitCountry { get; set; }
         /// <summary>
         /// 出访目的
@@ -125,10 +125,11 @@ namespace OASystem.Domain.Entities.Groups
         /// <summary>
         /// 预算成本
         /// </summary>
-        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
-        public string BudgetCost { get; set; }
+        [SugarColumn(IsNullable = true, ColumnDataType = "decimal(10,2)")]
+        public decimal BudgetCost { get; set; }
         /// <summary>
-        /// 是否操作完成 0否1是
+        /// 是否操作完成 
+        /// 0否1是
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "int")]
         public int IsSure { get; set; }
@@ -140,12 +141,12 @@ namespace OASystem.Domain.Entities.Groups
         /// <summary>
         /// 手机号
         /// </summary>
-        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(20)")]
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(500)")]
         public string TellPhone { get; set; }
         /// <summary>
         /// 团组客户级别
         /// </summary>
-        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(100)")]
         public string TeamLev { get; set; }
         /// <summary>
         /// 酒店投诉标识 0-未投诉1-已投诉
@@ -185,8 +186,8 @@ namespace OASystem.Domain.Entities.Groups
         /// <summary>
         /// 支付款项(预付)
         /// </summary>
-        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(50)")]
-        public string PaymentMoney { get; set; }
+        [SugarColumn(IsNullable = true, ColumnDataType = "decimal(10,2)")]
+        public decimal PaymentMoney { get; set; }
         /// <summary>
         /// 预付期限
         /// </summary>

+ 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();

+ 8 - 3
OASystem/OASystem.Infrastructure/Repositories/Login/LoginRepository.cs

@@ -27,14 +27,19 @@ namespace OASystem.Infrastructure.Repositories.Login
         public async Task<Result> Login(LoginDto loginDto)
         {
             Result result = new Result() { Code = -2 };
-            string SQLWhere = string.Format("Where Number='{0}' And Password='{1}'", loginDto.Number, loginDto.Password);
+            string SQLWhere = string.Format("Where Number='{0}'", loginDto.Number);
             string sql = string.Format("Select * From Sys_Users With(NoLock) {0}", SQLWhere);
             Sys_Users _entity = await GetSingleInfoBySqlWithNolockAsync(sql);
 
-
             if (_entity == null)
             {
-                result.Msg = "暂无该账号信息!";
+                result.Msg = "暂无该账户信息!";
+                return result;
+            }
+
+            if (_entity.Password != loginDto.Password)
+            {
+                result.Msg = "账户或密码错误!";
                 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)
+        {
+        }
+    }
+}