修改权限体系,增加标书信息管理权限分离,分为标书信息管理平台使用,和标书制作管理使用,修改权限表,订单表
4个文件已修改
219 ■■■■■ 已修改文件
DocumentServiceAPI.Model/Oder/Oder.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DocumentServiceAPI.Model/Permissions/TenantPermissions.cs 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DocumentServiceApi.InitQMessage/MessageReceive.cs 179 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DocumentServiceApi.InitQMessage/TenantOderInfo.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DocumentServiceAPI.Model/Oder/Oder.cs
@@ -66,8 +66,12 @@
        /// <summary>
        /// 是否具有标书编辑权限
        /// </summary>
        public bool? HasDocumentPermission { get; set; } = false;
        public bool HasDocumentPermission { get; set; } = false;
        /// <summary>
        /// 是否有权限
        /// </summary>
        [Display(Name = "是否有管理权限 ")]
        public bool HasManagePermission { get; set; } = false;
    }
}
DocumentServiceAPI.Model/Permissions/TenantPermissions.cs
@@ -2,6 +2,7 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
@@ -57,9 +58,30 @@
        [Display(Name = "描述 ")]
        [SugarColumn(ColumnDescription = "描述 ")]
        public string? Description { get; set; }
        /// <summary>
        /// 是否有标书编辑权限
        /// 权限分类
        /// </summary>
        public bool? HasDocumentPermission { get; set; } = false;
        public TenantPermissionsType PermissionsType { get; set; }
    }
    /// <summary>
    /// 权限表类型
    /// </summary>
    public enum TenantPermissionsType
    {
        /// <summary>
        /// 管理系统
        /// </summary>
        [Description( "管理系统权限")]
        Manage,
        /// <summary>
        ///  标书制作
        /// </summary>、
        [Description("管理系统权限")]
        Document
    }
}
DocumentServiceApi.InitQMessage/MessageReceive.cs
@@ -78,7 +78,10 @@
                };
                TenantPermissions permissions = new TenantPermissions()
                TenantPermissions ? Mangerpermissions = null;
                if (oder.HasManagePermission)
                {
                    Mangerpermissions = new TenantPermissions()
                {
                    CreatBy = "消息队列 InitTenantOder",
                    CreatTime = DateTime.Now,
@@ -86,12 +89,31 @@
                    EmployeeMaxCount = obj.EmployeeCount ?? 0,
                    UnitMaxCount = obj.UnitCount ?? 0,
                     
                     HasDocumentPermission=obj.HasDocumentPermission,
                        PermissionsType = TenantPermissionsType.Manage,
                    OverTime = DateTime.Now.AddMonths(obj.MonthCount ?? 0),
                };
                }
                TenantPermissions? DocumentPermissions = null;
                if (oder.HasDocumentPermission == true)
                {
                    DocumentPermissions = new TenantPermissions()
                    {
                        CreatBy = "消息队列 InitTenantOder",
                        CreatTime = DateTime.Now,
                        Description = obj.Description,
                        EmployeeMaxCount = obj.EmployeeCount ?? 0,
                        UnitMaxCount = obj.UnitCount ?? 0,
                        PermissionsType = TenantPermissionsType.Document,
                        OverTime = DateTime.Now.AddMonths(obj.MonthCount ?? 0),
                    };
                }
                //新建租户员工
                Document_EmployeeInfo employeeInfo = new Document_EmployeeInfo()
@@ -134,13 +156,22 @@
                  var id=  await _db.Insertable(Tinfo).ExecuteReturnIdentityAsync();
                    var eid = await _db.Insertable(employeeInfo).ExecuteReturnIdentityAsync();
                    permissions.TenantId = id;
                    if (Mangerpermissions != null)
                    {
                        Mangerpermissions.TenantId = id;
                        await _db.Insertable(Mangerpermissions).ExecuteCommandAsync();
                    }
                    if (DocumentPermissions != null)
                    {
                        DocumentPermissions.TenantId = id;
                        await _db.Insertable(DocumentPermissions).ExecuteCommandAsync();
                    }
                    employeeAtTenant.TenantID = id;
                    employeeAtTenant.EmployeeID = eid;
                    tenderUnit.TenantId = id;
                    await _db.Insertable(tenderUnit).ExecuteCommandAsync();
                    await _db.Insertable(employeeAtTenant).ExecuteCommandAsync();
                    await _db.Insertable(permissions).ExecuteCommandAsync ();
                    await _db.Insertable(oder).ExecuteCommandAsync();
                    await _db.AsTenant().CommitTranAsync();
                }
@@ -165,8 +196,9 @@
                Tinfo.UpdataTime = DateTime.Now;
                Tinfo.IsDel = false;
                Tinfo.IsEn = true;
              var tp= await _db.Queryable<TenantPermissions>().Where(x=>x.TenantId==Tinfo.Id).FirstAsync();
                if (oder.HasManagePermission == true)
                {
                    var tp = await _db.Queryable<TenantPermissions>().Where(x => x.TenantId == Tinfo.Id&&x.PermissionsType== TenantPermissionsType.Manage && x.IsEn == true && x.IsDel == false).FirstAsync();
                try
                {
@@ -188,6 +220,7 @@
                                 UnitMaxCount=obj.UnitCount??0,
                                  OverTime=DateTime.Now.AddMinutes(obj.MonthCount??0),
                                   TenantId= Tinfo.Id,
                                 PermissionsType= TenantPermissionsType.Manage,
                                   
                        };
                        await _db.Insertable(tp).ExecuteCommandAsync();
@@ -230,6 +263,140 @@
                    $"修改租户权限失败 msg:{msg},e:{e.ToString()}  By:消息队列 InitTenantOder".LogInformation<MessageReceive>();
                    return;
                }
                }
                if (oder.HasDocumentPermission == true)
                {
                    var tp = await _db.Queryable<TenantPermissions>().Where(x => x.TenantId == Tinfo.Id && x.PermissionsType == TenantPermissionsType.Document && x.IsEn == true && x.IsDel == false).FirstAsync();
                    try
                    {
                        await _db.AsTenant().BeginTranAsync();
                        if (Tinfo.ItCode != obj.ITCode)
                        {
                            await _db.Updateable(Tinfo).ExecuteCommandAsync();
                        };
                        if (tp == null)
                        {
                            tp = new TenantPermissions()
                            {
                                CreatBy = "消息队列 InitTenantOder",
                                CreatTime = DateTime.Now,
                                IsDel = false,
                                IsEn = true,
                                EmployeeMaxCount = obj.EmployeeCount ?? 0,
                                UnitMaxCount = obj.UnitCount ?? 0,
                                OverTime = DateTime.Now.AddMinutes(obj.MonthCount ?? 0),
                                TenantId = Tinfo.Id,
                                PermissionsType = TenantPermissionsType.Document,
                            };
                            await _db.Insertable(tp).ExecuteCommandAsync();
                        }
                        else
                        {
                            tp.IsDel = false;
                            tp.IsEn = true;
                            tp.UnitMaxCount = obj.UnitCount ?? tp.UnitMaxCount;
                            tp.EmployeeMaxCount = obj.EmployeeCount ?? tp.EmployeeMaxCount;
                            tp.OverTime = tp.OverTime.AddMonths(obj.MonthCount ?? 0);
                            tp.UpdataBy = "消息队列 InitTenantOder";
                            tp.UpdataTime = DateTime.Now;
                            await _db.Updateable(tp).ExecuteCommandAsync();
                        }
                        if (obj.ITCode != Employee.UserName)
                        {
                            //如果发现用户名已经更改,则该集团员工用户名跟随更改
                            Employee.UserName = obj.ITCode;
                            Employee.LastUpdateName = "消息队列 InitTenantOder";
                            Employee.LastUpdateTime = DateTime.Now;
                            await _db.Updateable(Employee).ExecuteCommandAsync();
                        }
                        await _db.Insertable(oder).ExecuteCommandAsync();
                        await _db.AsTenant().CommitTranAsync();
                    }
                    catch (Exception e)
                    {
                        await _db.AsTenant().RollbackTranAsync();
                        $"修改租户权限失败 msg:{msg},e:{e.ToString()}  By:消息队列 InitTenantOder".LogInformation<MessageReceive>();
                        return;
                    }
                }
                if(oder.HasDocumentPermission!=true&&oder.HasManagePermission!=true)
                {
                    //如果两个都不是,name就是增加人数或者增加公司数量,只有在管理系统中产生
                    var tp = await _db.Queryable<TenantPermissions>().Where(x => x.TenantId == Tinfo.Id && x.PermissionsType == TenantPermissionsType.Manage&&x.IsEn==true&&x.IsDel==false).FirstAsync();
                    try
                    {
                        await _db.AsTenant().BeginTranAsync();
                        if (Tinfo.ItCode != obj.ITCode)
                        {
                            await _db.Updateable(Tinfo).ExecuteCommandAsync();
                        };
                        if (tp == null)
                        {
                            //没有TP 则不直接增加 报错
                            await _db.AsTenant().RollbackTranAsync();
                            $"修改员工人数,公司员工权限失败 已丢弃处理 msg:{msg}  By:消息队列 InitTenantOder".LogInformation<MessageReceive>();
                            return;
                        }
                        else
                        {
                            tp.IsDel = false;
                            tp.IsEn = true;
                            tp.UnitMaxCount = tp.UnitMaxCount+=(obj.UnitCount??0);
                            tp.EmployeeMaxCount = tp.UnitMaxCount += (obj.UnitCount ?? 0);
                            tp.OverTime = tp.OverTime.AddMonths(obj.MonthCount ?? 0);
                            tp.UpdataBy = "消息队列 InitTenantOder";
                            tp.UpdataTime = DateTime.Now;
                            await _db.Updateable(tp).ExecuteCommandAsync();
                        }
                        if (obj.ITCode != Employee.UserName)
                        {
                            //如果发现用户名已经更改,则该集团员工用户名跟随更改
                            Employee.UserName = obj.ITCode;
                            Employee.LastUpdateName = "消息队列 InitTenantOder";
                            Employee.LastUpdateTime = DateTime.Now;
                            await _db.Updateable(Employee).ExecuteCommandAsync();
                        }
                        await _db.Insertable(oder).ExecuteCommandAsync();
                        await _db.AsTenant().CommitTranAsync();
                        return;
                    }
                    catch (Exception e)
                    {
                        await _db.AsTenant().RollbackTranAsync();
                        $"修改租户权限失败 msg:{msg},e:{e.ToString()}  By:消息队列 InitTenantOder".LogInformation<MessageReceive>();
                        return;
                    }
                }
            
            }
        
DocumentServiceApi.InitQMessage/TenantOderInfo.cs
@@ -61,8 +61,12 @@
        /// <summary>
        /// 是否具有标书编辑权限
        /// </summary>
        public bool? HasDocumentPermission { get; set; } = false;
        public bool HasDocumentPermission { get; set; } = false;
        /// <summary>
        /// 是否有权限
        /// </summary>
        public bool HasManagePermission { get; set; } = false;
    }
}