예제 #1
0
        /// <summary>
        /// 使用新模块创建权限
        /// </summary>
        /// <param name="privilegeAdd"></param>
        /// <returns></returns>
        public int AddPrivilegeForNewGroup(PrivilegeAddForNewGroupDto privilegeAdd)
        {
            TPrivilegeGroup privilegeGroup = new TPrivilegeGroup
            {
                Id       = IdentityHelper.NewSequentialGuid().ToString("N"),
                Name     = privilegeAdd.GroupName,
                SystemId = privilegeAdd.SystemId
            };
            string     SystemCode = IocUnity.Get <RepositorySystem>().GetCode(privilegeAdd.SystemId);
            TPrivilege privilege  = new TPrivilege
            {
                Id           = IdentityHelper.NewSequentialGuid().ToString("N"),
                Code         = $"{SystemCode}-{privilegeAdd.Code}",
                OriginalCode = privilegeAdd.Code,
                Name         = privilegeAdd.Name,
                GroupId      = privilegeGroup.Id,
                Instruction  = privilegeAdd.Instruction
            };
            int count = 0;

            IocUnity.Get <RepositoryPrivilege>().DapperRepository.ExcuteTransaction(tranc =>
            {
                IocUnity.Get <RepositoryPrivilegeGroup>().Insert(privilegeGroup);
                count += IocUnity.Get <RepositoryPrivilege>().Insert(privilege);
            });
            return(count);
        }
예제 #2
0
        /// <summary>
        /// 添加权限组
        /// </summary>
        /// <param name="privilegeGroupAddDto"></param>
        /// <returns></returns>
        public int AddPrivilegeGroup(PrivilegeGroupAddDto privilegeGroupAddDto)
        {
            TPrivilegeGroup privilegeGroup = new TPrivilegeGroup
            {
                Id       = IdentityHelper.NewSequentialGuid().ToString("N"),
                Name     = privilegeGroupAddDto.Name,
                SystemId = privilegeGroupAddDto.SystemId
            };

            return(IocUnity.Get <RepositoryPrivilegeGroup>().Insert(privilegeGroup));
        }