Ejemplo n.º 1
0
        /// <summary>
        /// 删除权限记录
        /// </summary>
        /// <param name="keyValue"></param>
        public bool DeleteForm(string keyValue)
        {
            //service.DeleteForm(keyValue);
            RoleAuthorizeEntity entity = _entityService.FindEntity(keyValue);

            if (entity == null)
            {
                return(false);
            }
            _entityService.Delete(entity);
            return(true);
        }
Ejemplo n.º 2
0
        public async Task SubmitForm <TDto>(RoleEntity roleEntity, string[] permissionIds, TDto dto) where TDto : class
        {
            var isAdd = false;

            if (string.IsNullOrEmpty(roleEntity.F_Id))
            {
                roleEntity.F_Id = Common.GuId();
                isAdd           = true;
            }
            var moduledata = await _moduleApp.GetList();

            var buttondata = await _moduleButtonApp.GetList();

            var roleAuthorizeEntitys = new List <RoleAuthorizeEntity>();

            foreach (var itemId in permissionIds)
            {
                var roleAuthorizeEntity = new RoleAuthorizeEntity
                {
                    F_Id         = Common.GuId(),
                    F_ObjectType = 1,
                    F_ObjectId   = roleEntity.F_Id,
                    F_ItemId     = itemId
                };
                if (moduledata.Find(t => t.F_Id == itemId) != null)
                {
                    roleAuthorizeEntity.F_ItemType = 1;
                }
                if (buttondata.Find(t => t.F_Id == itemId) != null)
                {
                    roleAuthorizeEntity.F_ItemType = 2;
                }
                roleAuthorizeEntitys.Add(roleAuthorizeEntity);
            }
            //_service.SubmitForm(roleEntity, roleAuthorizeEntitys, keyValue);
            //_service.BeginTrans();
            if (!isAdd)
            {
                await _service.UpdateAsync(roleEntity, dto);
            }
            else
            {
                roleEntity.F_Category = 1;
                await _service.InsertAsync(roleEntity, false);
            }

            await _serviceRA.DeleteAsync(t => t.F_ObjectId == roleEntity.F_Id);

            await _serviceRA.InsertAsync(roleAuthorizeEntitys);

            //_service.CommitTrans();
        }
Ejemplo n.º 3
0
 public void SubmitForm(RoleAuthorizeEntity entity, string keyValue)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         entity.Modify(keyValue);
         service.Update(entity);
     }
     else
     {
         entity.Create();
         service.Insert(entity);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 保存权限记录
 /// </summary>
 /// <param name="moduleEntity"></param>
 /// <param name="keyValue"></param>
 public void SubmitForm(RoleAuthorizeEntity roleAuthorizeEntity, string keyValue)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         roleAuthorizeEntity.F_Id = keyValue;
         service.Update(roleAuthorizeEntity);
     }
     else
     {
         roleAuthorizeEntity.Create();
         service.Insert(roleAuthorizeEntity);
     }
 }
        /// <summary>
        /// 保存角色资源授权
        /// </summary>
        /// <param name="roleId">角色Id</param>
        /// <param name="resourceIds">资源Ids</param>
        public async Task <int> Save(string roleId, List <string> resourceIds)
        {
            await service.DeleteAsync(t => t.ObjectId == roleId && t.ObjectType == 1 && t.ItemType == 4);

            foreach (string resourceId in resourceIds)
            {
                RoleAuthorizeEntity entity = new RoleAuthorizeEntity();
                entity.AttachCreateInfo(context);
                entity.ItemId     = resourceId;
                entity.ItemType   = 4;
                entity.ObjectId   = roleId;
                entity.ObjectType = 1;
                await service.InsertAsync(entity);
            }
            return(await Task.FromResult(0));
        }
Ejemplo n.º 6
0
        public void SubmitForm(RoleEntity roleEntity, string[] permissionIds, string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                roleEntity.F_Id = keyValue;
            }
            else
            {
                roleEntity.F_Id = Common.GuId();
            }
            var moduledata = moduleApp.GetList();
            var buttondata = moduleButtonApp.GetList();
            List <RoleAuthorizeEntity> roleAuthorizeEntitys = new List <RoleAuthorizeEntity>();

            foreach (var itemId in permissionIds)
            {
                RoleAuthorizeEntity roleAuthorizeEntity = new RoleAuthorizeEntity();
                roleAuthorizeEntity.F_Id         = Common.GuId();
                roleAuthorizeEntity.F_ObjectType = 1;
                roleAuthorizeEntity.F_ObjectId   = roleEntity.F_Id;
                roleAuthorizeEntity.F_ItemId     = itemId;
                if (moduledata.Find(t => t.F_Id == itemId) != null)
                {
                    roleAuthorizeEntity.F_ItemType = 1;
                }
                if (buttondata.Find(t => t.F_Id == itemId) != null)
                {
                    roleAuthorizeEntity.F_ItemType = 2;
                }
                roleAuthorizeEntitys.Add(roleAuthorizeEntity);
            }
            service.SubmitForm(roleEntity, roleAuthorizeEntitys, keyValue);

            try
            {
                //添加日志
                LogMess.addLog(DbLogType.Update.ToString(), "修改成功", "修改角色信息【" + roleEntity.F_FullName + "】成功!");
            }
            catch { }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 保存角色及角色菜单授权
        /// </summary>
        /// <param name="roleEntity">角色对象</param>
        /// <param name="permissionIds">菜单授权Id</param>
        /// <param name="keyValue">角色Id</param>
        public async Task <int> Save(RoleEntity roleEntity, string[] permissionIds, string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                roleEntity.Id = keyValue;
            }
            else
            {
                roleEntity.Id = Common.GuId();
            }
            var menuData = await menuApp.GetList();

            var buttonData = await moduleButtonApp.GetList();

            List <RoleAuthorizeEntity> roleAuthorizeEntitys = new List <RoleAuthorizeEntity>();

            foreach (var itemId in permissionIds)
            {
                RoleAuthorizeEntity roleAuthorizeEntity = new RoleAuthorizeEntity();
                roleAuthorizeEntity.Id         = Common.GuId();
                roleAuthorizeEntity.ObjectType = 1;
                roleAuthorizeEntity.ObjectId   = roleEntity.Id;
                roleAuthorizeEntity.ItemId     = itemId;
                if (menuData.Find(t => t.Id == itemId) != null)
                {
                    roleAuthorizeEntity.ItemType = 1;
                }
                if (buttonData.Find(t => t.Id == itemId) != null)
                {
                    roleAuthorizeEntity.ItemType = 2;
                }
                roleAuthorizeEntitys.Add(roleAuthorizeEntity);
            }
            //保存菜单授权
            return(await service.SaveAsync(roleEntity, roleAuthorizeEntitys, keyValue));
        }
 public ActionResult SubmitForm(RoleAuthorizeEntity moduleEntity, string keyValue)
 {
     roleAuthorizeApp.SubmitForm(moduleEntity, keyValue);
     return(Success("操作成功。"));
 }
Ejemplo n.º 9
0
 public void Delete(RoleAuthorizeEntity entity)
 {
     service.Delete(entity);
 }
Ejemplo n.º 10
0
 public RoleAuthorizeEntity SaveFrom(RoleAuthorizeEntity saveModel)
 {
     return(Save(saveModel, "roleauthor_"));
 }
Ejemplo n.º 11
0
        public async Task SubmitForm(RoleEntity roleEntity, string[] permissionIds, string[] permissionfieldsIds, string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                roleEntity.F_Id = keyValue;
            }
            else
            {
                roleEntity.F_DeleteMark  = false;
                roleEntity.F_AllowEdit   = false;
                roleEntity.F_AllowDelete = false;
                roleEntity.Create();
            }
            var moduledata = await moduleApp.GetList();

            var buttondata = await moduleButtonApp.GetList();

            var fieldsdata = await moduleFieldsApp.GetList();

            List <RoleAuthorizeEntity> roleAuthorizeEntitys = new List <RoleAuthorizeEntity>();

            foreach (var itemId in permissionIds)
            {
                RoleAuthorizeEntity roleAuthorizeEntity = new RoleAuthorizeEntity();
                roleAuthorizeEntity.F_Id         = Utils.GuId();
                roleAuthorizeEntity.F_ObjectType = 1;
                roleAuthorizeEntity.F_ObjectId   = roleEntity.F_Id;
                roleAuthorizeEntity.F_ItemId     = itemId;
                if (moduledata.Find(t => t.F_Id == itemId) != null)
                {
                    roleAuthorizeEntity.F_ItemType = 1;
                    roleAuthorizeEntitys.Add(roleAuthorizeEntity);
                }
                if (buttondata.Find(t => t.F_Id == itemId) != null)
                {
                    roleAuthorizeEntity.F_ItemType = 2;
                    roleAuthorizeEntitys.Add(roleAuthorizeEntity);
                }
            }
            foreach (var itemId in permissionfieldsIds)
            {
                RoleAuthorizeEntity roleAuthorizeEntity = new RoleAuthorizeEntity();
                roleAuthorizeEntity.F_Id         = Utils.GuId();
                roleAuthorizeEntity.F_ObjectType = 1;
                roleAuthorizeEntity.F_ObjectId   = roleEntity.F_Id;
                roleAuthorizeEntity.F_ItemId     = itemId;
                if (fieldsdata.Find(t => t.F_Id == itemId) != null)
                {
                    roleAuthorizeEntity.F_ItemType = 3;
                    roleAuthorizeEntitys.Add(roleAuthorizeEntity);
                }
            }
            uniwork.BeginTrans();
            if (!string.IsNullOrEmpty(keyValue))
            {
                await repository.Update(roleEntity);
            }
            else
            {
                roleEntity.F_Category = 1;
                await repository.Insert(roleEntity);
            }
            await uniwork.Delete <RoleAuthorizeEntity>(t => t.F_ObjectId == roleEntity.F_Id);

            await uniwork.Insert(roleAuthorizeEntitys);

            uniwork.Commit();
            await CacheHelper.Remove(cacheKey + keyValue);

            await CacheHelper.Remove(cacheKey + "list");

            await CacheHelper.Remove(authorizecacheKey + "list");

            await CacheHelper.Remove(authorizecacheKey + "authorize_list");

            await CacheHelper.Remove(initcacheKey + "modulebutton_list");

            await CacheHelper.Remove(initcacheKey + "modulefields_list");

            await CacheHelper.Remove(initcacheKey + "list");
        }