예제 #1
0
        public async Task <ActionResult> DeleteFilterRule(long id)
        {
            var result = new JsonModel {
                statusCode = 300, message = "删除失败,记录不存在!", closeCurrent = false
            };

            if (id < 1)
            {
                return(Json(result));
            }
            var model = await UserRole2FilterRepository.GetUnDeleteByIdAsync(id);

            if (model == null)
            {
                return(Json(result));
            }
            await UserRole2FilterRepository.Delete(model);

            UserRoleSvc.ClearRoleUserCache(model.RoleId);
            await LogRepository.Insert(TableSource.UserRole2Filter, OperationType.Delete, "删除角色数据规则" + model.Name, id);

            result.statusCode = 200;
            result.message    = "删除成功!";
            return(Json(result));
        }
예제 #2
0
        public ActionResult SaveButtons(long id, string btnIds)
        {
            var result = new JsonModel();

            if (string.IsNullOrEmpty(btnIds))
            {
                result.msg = "请选择按钮!";
                return(Json(result));
            }
            UserRole2MenuRepository.SaveRole2MenuButtons(id, btnIds);
            UserRoleSvc.ClearRoleUserCache(id);
            result.msg  = "保存成功!";
            result.code = JsonModelCode.Succ;
            return(Json(result));
        }
예제 #3
0
        public async Task <ActionResult> SetButtons(long roleId, string btnIds)
        {
            var result = new JsonModel();

            if (string.IsNullOrEmpty(btnIds))
            {
                result.statusCode = 300;
                result.message    = "请选择按钮!";
                return(Json(result));
            }
            await UserRole2MenuRepository.SaveRole2MenuButtons(roleId, btnIds);

            UserRoleSvc.ClearRoleUserCache(roleId);
            result.message = "保存成功!";
            return(Json(result));
        }
예제 #4
0
        public async Task <ActionResult> SetFilterRule(long id, string filterGroup, string name, string source, long roleId)
        {
            var result = new JsonModel();
            var exist  = await UserRole2FilterRepository.ExistSourceAsync(id, source);

            if (exist)
            {
                result.statusCode = 300;
                result.message    = $"已存在资源为{source}的角色数据规则!";
                return(Json(result));
            }
            UserRole2Filter userFilter = null;

            if (id > 0)
            {
                userFilter = await UserRole2FilterRepository.GetByIdAsync(id);

                if (userFilter == null)
                {
                    result.statusCode = 300;
                    result.message    = $"找不到Id为{id}的角色数据规则关联数据!";
                    return(Json(result));
                }
            }
            else
            {
                userFilter = DbFactory.CreateUserRole2Filter();
            }
            userFilter.RoleId       = roleId;
            userFilter.Name         = name;
            userFilter.Source       = source;
            userFilter.FilterGroups = filterGroup;
            await UserRole2FilterRepository.SaveAsync(userFilter);

            UserRoleSvc.ClearRoleUserCache(userFilter.RoleId);
            result.message = "保存成功!";
            var propModelList = GetPropertyList(source);

            userFilter.SourceProperties = propModelList;
            result.Data = userFilter;
            return(Json(result));
        }