Browse Source

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

yuanrf 1 week ago
parent
commit
f2c52c434f

+ 3 - 1
OASystem/EntitySync/Program.cs

@@ -144,6 +144,8 @@ db.CodeFirst.SetStringDefaultLength(50).BackupTable().InitTables(new Type[]
     //typeof(Grp_OfficialDutyLinkTranslator),//公务信息关联翻译人员 
     //typeof(Sys_DeviceToken),
     //typeof(Res_MediaSuppliers),//策划部供应商资料 
-    typeof(Res_BasicInsuranceCost)//保险国家基础费用 
+    //typeof(Res_BasicInsuranceCost)//保险国家基础费用 
+    //typeof(Grp_EnterExitCostPermission),//团组 - 出入境费用 --> 操作权限
+    //typeof(Grp_EnterExitCostDraftPermission)//团组 - 出入境费用 --> 操作权限-草稿
 });
 Console.WriteLine("数据库结构同步完成!");

+ 114 - 3
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -5400,14 +5400,19 @@ FROM
                     }
                 }
             }
-
+            var gj_jobPostIds = new List<int>() { 22, 32 };
+            var viewPermissionData = await _sqlSugar.Queryable<Sys_Users>()
+                .Where(x => x.IsDel == 0 && ((x.DepId == 7 && gj_jobPostIds.Contains(x.JobPostId)) || x.DepId == 6))
+                .Select(x => new { x.Id, Name = x.CnName })
+                .ToListAsync();
             return Ok(JsonView(true, "查询成功!", new
             {
                 GroupNameData = groupNameData.Data,
                 CurrencyData = _CurrencyData,
                 WordTypeData = _WordTypeData,
                 ExcelTypeData = _ExcelTypeData,
-                CurrencyInit = _currencyInfos
+                CurrencyInit = _currencyInfos,
+                ViewPermissionData = viewPermissionData
             }));
         }
 
@@ -5473,9 +5478,57 @@ FROM
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
         {
+            if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
+            if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
+
             return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
         }
 
+        /// <summary>
+        /// 团组模块 - 出入境费用 - 设置view权限
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
+        {
+            if (dto.CurrUserId < 1) return Ok(JsonView(false,MsgTips.UserId));
+            if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
+            if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
+
+            var permissions = new List<Grp_EnterExitCostPermission>();
+            foreach (var userId in dto.UserIds)
+            {
+                permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = dto.CurrUserId, CreateUserId = userId });
+            }
+            if (permissions.Any())
+            {
+                _sqlSugar.BeginTran();
+                try
+                {
+                    await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
+
+                    var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
+                    if (result < 1)
+                    {
+                        _sqlSugar.RollbackTran();
+                        return Ok(JsonView(false));
+                    }
+                }
+                catch (Exception ex)
+                {
+
+                    _sqlSugar.RollbackTran();
+                    return Ok(JsonView(false, ex.Message));
+                }
+                _sqlSugar.CommitTran();
+                return Ok(JsonView(true));
+
+            }
+            return Ok(JsonView(false));
+        }
+
+
         /// <summary>
         /// 团组模块 - 出入境费用 - Add And Update
         /// </summary>
@@ -7494,13 +7547,20 @@ FROM
                 }
             }
 
+            var gj_jobPostIds = new List<int>() { 22, 32 };
+            var viewPermissionData = await _sqlSugar.Queryable<Sys_Users>()
+                .Where(x => x.IsDel == 0 && ((x.DepId == 7 && gj_jobPostIds.Contains(x.JobPostId)) || x.DepId == 6))
+                .Select(x => new { x.Id, Name = x.CnName })
+                .ToListAsync();
+
             return Ok(JsonView(true, "查询成功!", new
             {
                 DraftNameDatas = draftNameDatas,
                 CurrencyData = _CurrencyData,
                 WordTypeData = _WordTypeData,
                 ExcelTypeData = _ExcelTypeData,
-                CurrencyInit = _currencyInfos
+                CurrencyInit = _currencyInfos,
+                ViewPermissionData = viewPermissionData
             }));
         }
 
@@ -7569,6 +7629,50 @@ FROM
             return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
         }
 
+        /// <summary>
+        /// 团组模块 - 出入境费用-草稿 - 设置view权限
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
+        {
+            if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
+            if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
+            if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
+
+            var permissions = new List<Grp_EnterExitCostDraftPermission>();
+            foreach (var userId in dto.UserIds)
+            {
+                permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = userId });
+            }
+            if (permissions.Any())
+            {
+                _sqlSugar.BeginTran();
+                try
+                {
+                    await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
+
+                    var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
+                    if (result < 1)
+                    {
+                        _sqlSugar.RollbackTran();
+                        return Ok(JsonView(false));
+                    }
+                }
+                catch (Exception ex)
+                {
+
+                    _sqlSugar.RollbackTran();
+                    return Ok(JsonView(false, ex.Message));
+                }
+                _sqlSugar.CommitTran();
+                return Ok(JsonView(true));
+
+            }
+            return Ok(JsonView(false));
+        }
+
         /// <summary>
         /// 团组模块 - 出入境费用-草稿 - Add And Update
         /// </summary>
@@ -7740,9 +7844,16 @@ FROM
                             airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
                         }
 
+                        string twoItemRemark = "备注:";
+                        if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
+                        {
+                            twoItemRemark = _EnterExitCosts.TwoItemRemark;
+                        }
+
                         dic.Add("AirTotalStr", airTotalStr);
                         dic.Add("AirPriceStr", airPriceStr);
                         dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
+                        dic.Add("TwoItemRemark", twoItemRemark);
 
                         NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
                         Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;

+ 10 - 0
OASystem/OASystem.Domain/Dtos/Groups/EnterExitCostDraftDto.cs

@@ -11,6 +11,14 @@ namespace OASystem.Domain.Dtos.Groups
     {
     }
 
+    public class EnterExitCostDraftSetViewPermissiionDto : PortDtoBase
+    {
+        public int[] UserIds { get; set; }
+        public int DraftId { get; set; }
+
+        public int CurrUserId { get; set; }
+    }
+
     /// <summary>
     /// 出入境费用详情 Dto
     /// </summary>
@@ -20,6 +28,8 @@ namespace OASystem.Domain.Dtos.Groups
         /// Id
         /// </summary>
         public int Id { get; set; }
+
+        public int CurrUserId { get; set; }
     }
 
     /// <summary>

+ 12 - 0
OASystem/OASystem.Domain/Dtos/Groups/EnterExitCostDto.cs

@@ -20,6 +20,8 @@ namespace OASystem.Domain.Dtos.Groups
         /// 团组Id
         /// </summary>
         public int DiId { get; set; }
+
+        public int CurrUserId { get; set; }
     }
 
     public class PostEnterExitCostMobileSubInfoDto : EnterExitCostInfobyDiIdDto
@@ -31,6 +33,16 @@ namespace OASystem.Domain.Dtos.Groups
         public int SubType { get; set; }
     }
 
+
+    public class EnterExitCostSetViewPermissiionDto: PortDtoBase
+    {
+        public int GroupId { get; set; }
+
+        public int[] UserIds { get; set; }
+
+        public int CurrUserId { get; set; }
+    }
+
     /// <summary>
     /// 出入境费用 Add And Update  Dto
     /// </summary>

+ 33 - 0
OASystem/OASystem.Domain/Entities/Groups/Grp_EnterExitCostDraftPermission.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Entities.Groups
+{
+
+    /// <summary>
+    /// 团组 - 出入境费用 --> 操作权限-草稿
+    /// </summary>
+    public class Grp_EnterExitCostDraftPermission : EntityBase
+    {
+        /// <summary>
+        /// 草稿Id
+        /// </summary>
+        [SugarColumn(ColumnDescription = "草稿Id", IsNullable = true, ColumnDataType = "int")]
+        public int DraftId { get; set; }
+
+        /// <summary>
+        /// 用户Id
+        /// </summary>
+        [SugarColumn(ColumnDescription = "用户Id", IsNullable = true, ColumnDataType = "int")]
+        public int UserId { get; set; }
+
+        /// <summary>
+        /// 权限功能ID(1:查看;2:新增;3:编辑;4:删除;5:下载;)
+        /// </summary>
+        [SugarColumn(ColumnDescription = "权限功能ID(1:查看;2:新增;3:编辑;4:删除;5:下载;)", IsNullable = true, ColumnDataType = "int")]
+        public int Permission { get; set; }
+    }
+}

+ 33 - 0
OASystem/OASystem.Domain/Entities/Groups/Grp_EnterExitCostPermission.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Entities.Groups
+{
+    /// <summary>
+    /// 团组 - 出入境费用 --> 操作权限
+    /// </summary>
+    [SugarTable("Grp_EnterExitCostPermission")]
+    public class Grp_EnterExitCostPermission : EntityBase
+    {
+        /// <summary>
+        /// 团组Id
+        /// </summary>
+        [SugarColumn(ColumnDescription = "团组Id", IsNullable = true,ColumnDataType = "int")]
+        public int GroupId { get; set; }
+
+        /// <summary>
+        /// 用户Id
+        /// </summary>
+        [SugarColumn(ColumnDescription = "用户Id", IsNullable = true, ColumnDataType = "int")]
+        public int UserId { get; set; }
+
+        /// <summary>
+        /// 权限功能ID(1:查看;2:新增;3:编辑;4:删除;5:下载;)
+        /// </summary>
+        [SugarColumn(ColumnDescription = "权限功能ID(1:查看;2:新增;3:编辑;4:删除;5:下载;)", IsNullable = true, ColumnDataType = "int")]
+        public int Permission { get; set; }
+    }
+}

+ 5 - 0
OASystem/OASystem.Domain/ViewModels/Groups/EnterExitCostDraftView.cs

@@ -17,6 +17,11 @@ namespace OASystem.Domain.ViewModels.Groups
     /// </summary>
     public class EnterExitCostDraftInfoView
     {
+        public bool IsSave { get; set; }
+        public bool IsView { get; set; } = false;
+
+        public int[] ViewUsers { get; set; }
+
         /// <summary>
         /// Id
         /// </summary>

+ 5 - 0
OASystem/OASystem.Domain/ViewModels/Groups/EnterExitCostView.cs

@@ -259,6 +259,11 @@ namespace OASystem.Domain.ViewModels.Groups
     /// </summary>
     public class EnterExitCostInfoView
     {
+        public bool IsSave { get; set; }
+        public bool IsView { get; set; } = false;
+
+        public int[] ViewUsers { get; set; }
+
         /// <summary>
         /// Id
         /// </summary>

+ 52 - 0
OASystem/OASystem.Infrastructure/Repositories/Groups/EnterExitCostDraftRepository.cs

@@ -29,6 +29,28 @@ namespace OASystem.Infrastructure.Repositories.Groups
             _mapper = mapper;
         }
 
+        /// <summary>
+        /// 出入境费用草稿 --> 权限验证
+        /// </summary>
+        /// <param name="groupId">草稿Id</param>
+        /// <param name="permission">操作权限 1:查看;2:新增;3:编辑;4:删除;5:下载; </param>
+        /// <returns></returns>
+        public async Task<bool> PermissionValidationAsync(int groupId, int permission)
+        {
+            //参数验证
+            if (groupId < 1) return false;
+            var permissionIds = new List<int>() { 1, 2, 3, 4, 5 };
+            if (!permissionIds.Contains(permission)) return false;
+
+            var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraftPermission>()
+                     .Where(it => it.DraftId == groupId && it.Permission == permission)
+                     .FirstAsync();
+            if (info != null) return true;
+
+            return false;
+        }
+
+
         /// <summary>
         /// 查询 根据 Id 查询
         /// </summary>
@@ -46,8 +68,28 @@ namespace OASystem.Infrastructure.Repositories.Groups
             {
                 if (enterExitCostDraftData != null)
                 {
+
                     enterExitCostInfoView = _mapper.Map<EnterExitCostDraftInfoView>(enterExitCostDraftData);
 
+                    var isView = await PermissionValidationAsync(enterExitCostDraftData.Id, dto.CurrUserId);
+
+                    if (isView) enterExitCostInfoView.IsView = true; //查看权限
+
+                    if (enterExitCostDraftData.CreateUserId == dto.CurrUserId)
+                    {
+                        enterExitCostInfoView.IsSave = true; //操作权限
+                        enterExitCostInfoView.IsView = true; //查看权限
+                    }
+
+                    if (!enterExitCostInfoView.IsView)
+                    {
+                        var setUserName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == enterExitCostDraftData.CreateUserId).Select(x => x.CnName).FirstAsync();
+
+                        result.Msg = $"{setUserName}设置了你不能查看当前团组的出入境费用明细数据-草稿,如要查看,请联系{setUserName}!";
+                        return result;
+                    }
+
+
                     var dayAndCostDraftSql = string.Format(@"Select ntf.Country,ntf.City,ssd.Name CurremcyCode,ssd.Remark CurrencyName,gdac.* From Grp_DayAndCostDraft gdac
                                                         Left Join Grp_NationalTravelFee ntf On ntf.Id = gdac.NationalTravelFeeId
                                                         Left Join Sys_SetData ssd On ssd.STid = 66 And gdac.Currency = ssd.Id
@@ -158,6 +200,16 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     var isNull = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.DraftName.Equals(dto.DraftName)).First();
                     if (isNull != null) //修改
                     {
+                        //编辑验证
+                        if (isNull.CreateUserId != dto.UserId)
+                        {
+                            var userName = _sqlSugar.Queryable<Sys_Users>().Where(x => isNull.CreateUserId == isNull.Id).Select(x => x.CnName).First();
+                            _sqlSugar.RollbackTran();
+                            result.Msg = $"该条信息只有操作人“{userName}”可修改!";
+                            return result;
+                        }
+
+
                         var updateId = _sqlSugar.Updateable(enterExitCost)
                                                 .IgnoreColumns(it => new { it.DeleteUserId, it.DeleteTime, it.CreateUserId, it.CreateTime, it.IsDel })
                                                 .WhereColumns(it => it.DraftName)

+ 61 - 6
OASystem/OASystem.Infrastructure/Repositories/Groups/EnterExitCostRepository.cs

@@ -25,7 +25,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
         private readonly IMapper _mapper;
         private readonly SetDataRepository _setDataRep;
 
-
         public EnterExitCostRepository(SqlSugarClient sqlSugar, IMapper mapper, SetDataRepository setDataRep)
             : base(sqlSugar)
         {
@@ -33,6 +32,27 @@ namespace OASystem.Infrastructure.Repositories.Groups
             _mapper = mapper;
         }
 
+        /// <summary>
+        /// 出入境费用正式 --> 权限验证
+        /// </summary>
+        /// <param name="groupId">团组Id</param>
+        /// <param name="permission">操作权限 1:查看;2:新增;3:编辑;4:删除;5:下载; </param>
+        /// <returns></returns>
+        public async Task<bool> PermissionValidationAsync(int groupId, int permission)
+        {
+            //参数验证
+            if (groupId < 1) return false;
+            var permissionIds = new List<int>() { 1, 2, 3, 4, 5 };
+            if (!permissionIds.Contains(permission)) return false;
+
+            var info = await _sqlSugar.Queryable<Grp_EnterExitCostPermission>()
+                     .Where(it => it.GroupId == groupId && it.Permission == permission)
+                     .FirstAsync();
+            if (info != null) return true;
+
+            return false;
+        }
+
         /// <summary>
         /// 更新出入境费用汇率信息
         /// </summary>
@@ -83,6 +103,30 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 if (enterExitCostData != null)
                 {
                     enterExitCostInfoView = _mapper.Map<EnterExitCostInfoView>(enterExitCostData);
+
+                    var isView = await PermissionValidationAsync(dto.DiId, dto.CurrUserId);
+                    if (isView) enterExitCostInfoView.IsView = true; //查看权限
+
+                    if (enterExitCostData.CreateUserId == dto.CurrUserId) {
+                        enterExitCostInfoView.IsSave = true; //操作权限
+                        enterExitCostInfoView.IsView = true; //查看权限
+                    }
+
+
+                    if (!enterExitCostInfoView.IsView)
+                    {
+                        var setUserName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == enterExitCostData.CreateUserId).Select(x => x.CnName).FirstAsync();
+
+                        result.Msg = $"{setUserName}设置了你不能查看当前团组的出入境费用明细数据,如要查看,请联系{setUserName}!";
+                        return result;
+                    }
+
+                    enterExitCostInfoView.ViewUsers = await _sqlSugar
+                        .Queryable<Grp_EnterExitCostPermission>()
+                        .Where(x => x.GroupId == dto.DiId)
+                        .Select(x => x.UserId)
+                        .ToArrayAsync();
+
                     //enterExitCostInfoView.FirstItemRemark = enterExitCostData.Remark;
                     var dayAndCostSql = string.Format(@"Select ntf.Country,ntf.City,ssd.Name CurremcyCode,ssd.Remark CurrencyName,gdac.* From Grp_DayAndCost gdac
                                                         Left Join Grp_NationalTravelFee ntf On ntf.Id = gdac.NationalTravelFeeId
@@ -135,7 +179,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     //    enterExitCostInfoView.MiscellaneousFeeData = views;
                     //    enterExitCostInfoView.TrainingExpenseData = views;
                     //    result.Code = 0;
-                    result.Msg = "未查询出数据!!!";
+                    enterExitCostInfoView.IsView = true;
+                    enterExitCostInfoView.IsSave = true;
+                    result.Msg = "未查询出数据!可操作该条数据!";
                 }
 
                 result.Data = enterExitCostInfoView;
@@ -269,6 +315,19 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     
                     if (enterExitCost.Id > 0) //修改
                     {
+                        //操作权限验证 只有创建人可修改
+                        var info = await _sqlSugar.Queryable<Grp_EnterExitCost,Sys_Users>((eec,u) => new JoinQueryInfos(JoinType.Left,eec.CreateUserId == u.Id))
+                            .Where(it => it.IsDel == 0 && it.Id == enterExitCost.Id)
+                            .Select((eec, u) => new { eec.CreateUserId,u.CnName })
+                            .FirstAsync();
+                        if (info.CreateUserId != dto.UserId)
+                        {
+                            
+                            _sqlSugar.RollbackTran();
+                            result.Msg = $"该条信息只有操作人“{info.CnName}”可修改!";
+                            return result;
+                        }
+
                         //修改验证
                         //IsConfirm == 2 不可修改
                         //var info = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.Id == enterExitCost.Id).First();
@@ -386,7 +445,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
             return _view;
         }
 
-
         /// <summary>
         /// Del
         /// </summary>
@@ -519,8 +577,5 @@ namespace OASystem.Infrastructure.Repositories.Groups
             return result;
         }
 
-
-
-
     }
 }