/// <summary> /// 删除栏目与菜单之间的关联关系 /// </summary> /// <param name="keyValue">菜单Id</param> /// <param name="ColumnId">栏目ID</param> /// <returns></returns> public ActionResult RemoveAssociation(string ModuleId, string ColumnId) { try { AppSettingAssociationBLL associationBLL = new AppSettingAssociationBLL(); AppSettingAssociationEntity association = associationBLL.GetEntity(ModuleId, ColumnId); //========因页面上的授权都改为了级联添加,删除也要做成级联删除===hm====// //1、先找查询出所有的菜单,然后递归找出所有的子级菜单 List <MenuConfigEntity> menuConfigEntities = new MenuConfigBLL().GetAllList(); List <MenuConfigEntity> childMenus = new List <MenuConfigEntity>(); childMenus.Add(menuConfigEntities.FirstOrDefault(p => p.ModuleId == ModuleId)); //当前项也要删除 MenuTreeHelper.FindAllChild(menuConfigEntities, childMenus, ModuleId); //找出所有的下级菜单 //====================END==============================// associationBLL.Remove(childMenus.Select(x => x.ModuleId).ToList(), ColumnId); //判断该菜单是不是安卓终端的,是的话就更新版本 var module = new MenuConfigBLL().GetEntity(ModuleId); if (module.PaltformType == 1) { MenuAuthorizeEntity menuAuthorize = authorizeBLL.GetEntityByDeptId(association.DeptId); if (menuAuthorize != null) { authorizeBLL.SaveForm(menuAuthorize.Id, menuAuthorize);//此处单纯的改变一下版本号 } } return(Success("操作成功。")); } catch (Exception ex) { return(Error("操作失败:" + ex.Message)); } }
public async Task SaveRoleAuth(long roleId, string menuIds) { var items = await _menuAuthorizeEntityDB.Where(a => a.AuthorizeId == roleId).ToListAsync(); foreach (var item in items) { await item.DeleteNowAsync(); } // 角色对应的菜单、页面和按钮权限 if (!string.IsNullOrEmpty(menuIds)) { foreach (var menuId in TextHelper.SplitToArray <long>(menuIds, ',')) { var menuAuthorizeEntity = new MenuAuthorizeEntity(); menuAuthorizeEntity.AuthorizeId = roleId; menuAuthorizeEntity.MenuId = menuId; menuAuthorizeEntity.AuthorizeType = AuthorizeTypeEnum.Role.ParseToInt(); menuAuthorizeEntity.Id = IdGeneratorHelper.Instance.GetId(); menuAuthorizeEntity.CreatorId = NetHelper.HttpContext.User.FindFirstValue("UserId").ParseToLong(); menuAuthorizeEntity.CreateTime = DateTime.Now; await _menuAuthorizeEntityDB.InsertNowAsync(menuAuthorizeEntity); } } }
public async Task <TData <string> > SaveForm(MenuAuthorizeEntity entity) { var obj = new TData <string>(); await _menuAuthorizeService.SaveForm(entity); obj.Data = entity.Id.ParseToString(); obj.Tag = 1; return(obj); }
/// <summary> /// 批量保存栏目与菜单的关系 /// </summary> /// <param name="postData"></param> /// <returns></returns> public ActionResult BatchSaveAssociationSetting(BatchAssociationRequestModel postData) { try { AppSettingAssociationBLL associationBLL = new AppSettingAssociationBLL(); MenuConfigBLL menuConfigBLL = new MenuConfigBLL(); List <MenuConfigEntity> menuConfigEntities = MenuConfigBLL.GetList(null, postData.PaltformType).ToList();//所有的菜单,获取排序用 //先找出该栏目数据库里已存在的关联关系 List <AppSettingAssociationEntity> associationEntities = associationBLL.GetListByColumnId(postData.ColumnId); List <string> associationModuleIds = associationEntities.Select(x => x.ModuleId).ToList(); if (postData.ModuleIds != null && postData.ModuleIds.Count > 0) { //找出要新增的Id List <string> addIds = postData.ModuleIds.Where(x => !associationModuleIds.Contains(x)).ToList(); //数据库里面没有的,则是要新增的 //找出要删除的Id List <string> delIds = associationModuleIds.Where(p => !postData.ModuleIds.Contains(p)).ToList(); //数据库有 ,但是前台传入的ID集合里没有的,则是要删除的 //构建新增的实体 List <AppSettingAssociationEntity> inserEntities = new List <AppSettingAssociationEntity>(); addIds.ForEach(moduleId => { var module = menuConfigEntities.FirstOrDefault(x => x.ModuleId == moduleId); inserEntities.Add(new AppSettingAssociationEntity() { Id = Guid.NewGuid().ToString(), ColumnId = postData.ColumnId, ColumnName = postData.ColumnName, DeptId = postData.DeptId, ModuleId = moduleId, Sort = module == null ? null : module.Sort }); }); associationBLL.InsertList(inserEntities); associationBLL.Remove(postData.DeptId, delIds); } else { associationBLL.Remove(postData.DeptId, associationModuleIds); } //判断该菜单是不是安卓终端的,是的话就更新版本 if (postData.PaltformType == 1) { MenuAuthorizeEntity menuAuthorize = authorizeBLL.GetEntityByDeptId(postData.DeptId); if (menuAuthorize != null) { authorizeBLL.SaveForm(menuAuthorize.Id, menuAuthorize);//此处单纯的改变一下版本号 } } return(Success("保存成功")); } catch (Exception ex) { return(Error("保存失败:" + ex.Message)); } }
public async Task SaveForm(MenuAuthorizeEntity entity) { if (entity.Id.IsNullOrZero()) { await entity.Create(); await this.BaseRepository().Insert(entity); } else { await this.BaseRepository().Update(entity); } }
/// <summary> /// 保存菜单设置 /// </summary> /// <param name="keyValue"></param> /// <param name="entity"></param> /// <returns></returns> public ActionResult SaveMenuSetting(string keyValue, AppMenuSettingEntity entity) { AppMenuSettingBLL settingBLL = new AppMenuSettingBLL(); settingBLL.SaveForm(keyValue, entity); //判断该菜单是不是安卓终端的,是的话就更新版本 MenuAuthorizeEntity menuAuthorize = authorizeBLL.GetEntityByDeptId(entity.DeptId); if (menuAuthorize != null) { authorizeBLL.SaveForm(menuAuthorize.Id, menuAuthorize); //此处单纯的改变一下版本号 } return(Success("操作成功。")); }
public async Task SaveForm(MenuAuthorizeEntity entity) { if (entity.Id.IsNullOrZero()) { // 默认赋值 entity.Id = IdGeneratorHelper.Instance.GetId(); await _menuAuthorizeEntityDB.InsertNowAsync(entity); } else { // 默认赋值 await _menuAuthorizeEntityDB.UpdateNowAsync(entity, ignoreNullValues : true); } }
/// <summary> /// 保存菜单与栏目的关系 /// </summary> /// <param name="keyValue"></param> /// <param name="entity"></param> /// <returns></returns> public ActionResult SaveMenuAssociationSetting(string keyValue, AppSettingAssociationEntity entity) { AppSettingAssociationBLL associationBLL = new AppSettingAssociationBLL(); associationBLL.SaveForm(keyValue, entity); //判断该菜单是不是安卓终端的,是的话就更新版本 var module = new MenuConfigBLL().GetEntity(entity.ModuleId); if (module.PaltformType == 1) { MenuAuthorizeEntity menuAuthorize = authorizeBLL.GetEntityByDeptId(entity.DeptId); if (menuAuthorize != null) { authorizeBLL.SaveForm(menuAuthorize.Id, menuAuthorize);//此处单纯的改变一下版本号 } } return(Success("操作成功。")); }
public async Task SaveForm(RoleEntity entity) { var db = await this.BaseRepository().BeginTrans(); try { if (entity.Id.IsNullOrZero()) { await entity.Create(); await db.Insert(entity); } else { await db.Delete <MenuAuthorizeEntity>(t => t.AuthorizeId == entity.Id); await entity.Modify(); await db.Update(entity); } // 角色对应的菜单、页面和按钮权限 if (!string.IsNullOrEmpty(entity.MenuIds)) { foreach (long menuId in TextHelper.SplitToArray <long>(entity.MenuIds, ',')) { MenuAuthorizeEntity menuAuthorizeEntity = new MenuAuthorizeEntity(); menuAuthorizeEntity.AuthorizeId = entity.Id; menuAuthorizeEntity.MenuId = menuId; menuAuthorizeEntity.AuthorizeType = AuthorizeTypeEnum.Role.ParseToInt(); await menuAuthorizeEntity.Create(); await db.Insert(menuAuthorizeEntity); } } await db.CommitTrans(); } catch { await db.RollbackTrans(); throw; } }
/// <summary> /// 删除栏目(因为栏目Id是唯一的,所以不用根据platform平台类型去区分删除) /// </summary> /// <param name="keyValue">栏目ID</param> /// <returns></returns> public ActionResult RemoveMenuSetting(string keyValue) { AppMenuSettingBLL settingBLL = new AppMenuSettingBLL(); AppMenuSettingEntity appMenu = settingBLL.GetEntity(keyValue); settingBLL.Remove(keyValue); AppSettingAssociationBLL associationBLL = new AppSettingAssociationBLL(); associationBLL.RemoveByColumnId(keyValue);//删除栏目与菜单的关联关系 //判断该菜单是不是安卓终端的,是的话就更新版本 if (appMenu.PlatformType == 1) { MenuAuthorizeEntity menuAuthorize = authorizeBLL.GetEntityByDeptId(appMenu.DeptId); if (menuAuthorize != null) { authorizeBLL.SaveForm(menuAuthorize.Id, menuAuthorize);//此处单纯的改变一下版本号 } } return(Success("操作成功。")); }
public async Task <List <MenuAuthorizeEntity> > GetList(MenuAuthorizeEntity param) { var expression = LinqExtensions.True <MenuAuthorizeEntity>(); if (param != null) { if (param.AuthorizeId.ParseToLong() > 0) { expression = expression.And(t => t.AuthorizeId == param.AuthorizeId); } if (param.AuthorizeType.ParseToInt() > 0) { expression = expression.And(t => t.AuthorizeType == param.AuthorizeType); } if (!param.AuthorizeIds.IsEmpty()) { long[] authorizeIdArr = TextHelper.SplitToArray <long>(param.AuthorizeIds, ','); expression = expression.And(t => authorizeIdArr.Contains(t.AuthorizeId.Value)); } } var list = await this.BaseRepository().FindList <MenuAuthorizeEntity>(expression); return(list.ToList()); }
public ActionResult CopyInfo(CopyRequestModel model) { if (!string.IsNullOrWhiteSpace(model.DeptId) && !string.IsNullOrWhiteSpace(model.Id)) { //先查询出授权信息 MenuAuthorizeEntity entity = authorizeBLL.GetEntity(model.Id); if (entity != null) { DepartmentBLL departmentBll = new DepartmentBLL(); var deptIdArry = model.DeptId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var deptCodeArry = model.DeptCode.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var deptNameArry = model.DeptName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); //菜单授权信息 DeptMenuAuthBLL deptMenuAuthBll = new DeptMenuAuthBLL(); List <DeptMenuAuthEntity> deptMenuAuthList = deptMenuAuthBll.GetList(entity.DepartId); //界面设置 List <AppMenuSettingEntity> appMenuSettingEntities = new AppMenuSettingBLL().GetListByDeptId(entity.DepartId); //栏目与菜单的关联关系 List <AppSettingAssociationEntity> appSettingAssociationList = new AppSettingAssociationBLL().GetList(entity.DepartId); List <DeptMenuAuthEntity> insetDeptMenuAuthList = new List <DeptMenuAuthEntity>(); List <MenuAuthorizeEntity> authorizeEntities = new List <MenuAuthorizeEntity>(); //复制之后要保存到数据库中的单位授权数据 List <AppMenuSettingEntity> insertMenuSettingEntities = new List <AppMenuSettingEntity>(); //界面设置 List <AppSettingAssociationEntity> insertAssociationEntities = new List <AppSettingAssociationEntity>(); //关联关系 for (int i = 0; i < deptIdArry.Length; i++) { //1、先复制单位的授权信息 DepartmentEntity deptEntity = departmentBll.GetEntity(deptIdArry[i]); MenuAuthorizeEntity insertEntity = new MenuAuthorizeEntity() { Id = Guid.NewGuid().ToString(), DepartId = deptIdArry[i], DepartCode = deptCodeArry[i], DepartName = deptNameArry[i], DisplayName = deptNameArry[i], BZApiUrl = entity.BZApiUrl, CreateDate = entity.CreateDate, CreateUserId = entity.CreateUserId, CreateUserName = entity.CreateUserName, CulturalUrl = entity.CulturalUrl, ModifyDate = entity.ModifyDate, ModifyUserId = entity.ModifyUserId, ModifyUserName = entity.ModifyUserName, PXApiUrl = entity.PXApiUrl, RegistCode = entity.RegistCode, SKApiUrl = entity.SKApiUrl, TerminalCode = entity.TerminalCode, ThemeType = entity.ThemeType, VersionCode = entity.VersionCode, ParentId = deptEntity != null? deptEntity.ParentId : "", ParentName = deptEntity != null && deptEntity.ParentId == "0" ? "" : departmentBll.GetEntity(deptEntity.ParentId).FullName }; authorizeEntities.Add(insertEntity); //2、复制界面设置 appMenuSettingEntities.ForEach(setting => { AppMenuSettingEntity appMenu = setting.Clone(deptIdArry[i], deptNameArry[i], deptCodeArry[i], appSettingAssociationList, insertAssociationEntities); insertMenuSettingEntities.Add(appMenu); }); //3、 复制关联关系 //appSettingAssociationList.ForEach(e => //{ // AppSettingAssociationEntity association = e.Clone(deptIdArry[i], ,insetDeptMenuAuthList); // insertAssociationEntities.Add(association); //}); //4、复制菜单授权信息 deptMenuAuthList.ForEach(p => { DeptMenuAuthEntity deptMenu = p.Clone(deptIdArry[i], deptCodeArry[i], deptNameArry[i]); insetDeptMenuAuthList.Add(deptMenu); }); } authorizeBLL.InsertEntity(authorizeEntities.ToArray()); new AppMenuSettingBLL().InsertList(insertMenuSettingEntities); new AppSettingAssociationBLL().InsertList(insertAssociationEntities); new DeptMenuAuthBLL().InsertList(insetDeptMenuAuthList); } } return(Success("操作成功")); }
public ActionResult SaveMenuAuth(MenuAuthRquestModel param) { try { //先从数据库提取出所有的该单位下的菜单。已经有的就不管,没有的就添加,多的就删除 var oldData = deptMenuAuthBLL.GetList(param.departId); //旧的数据 var delData = oldData.Where(x => !param.ModuleIds.Contains(x.ModuleId)).ToList(); //要删除逇数据; var oldmoduleIdsList = oldData.Select(x => x.ModuleId).ToList(); var newdataIds = param.ModuleIds.Where(x => !oldmoduleIdsList.Contains(x)).ToList();//要新增进去的数据Id的集合 var newData = new List <DeptMenuAuthEntity>(); newdataIds.ForEach(p => { newData.Add(new DeptMenuAuthEntity() { Id = Guid.NewGuid().ToString(), DeptCode = param.departCode, DeptId = param.departId, DeptName = param.departName, ModuleId = p }); }); //执行删除操作之前,判断是否有菜单已经被使用了,被适用的菜单,不允许取消授权。防止误操作 bool validData = new AppSettingAssociationBLL().CheckData(delData); if (!validData) { return(Error("操作失败:" + "存在正在被使用的菜单模块,请先删除“APP(安卓终端)界面设置”中工作栏里的菜单后再操作")); } deptMenuAuthBLL.Remove(delData); deptMenuAuthBLL.Add(newData); //取消了菜单授权之后 ,要删除对应的单位的栏目菜单关联关系 new AppSettingAssociationBLL().Remove(param.departId, delData.Select(p => p.ModuleId).ToList()); // 如果新增的数据里面有安卓终端的数据 ,则把这些菜单添加到默认栏目里面, 没有栏目的则默认新建一个栏目 //1、找出新增的菜单里面是安卓菜单的数据 List <MenuConfigEntity> newMenuEntityList = MenuConfigBLL.GetListByModuleIds(newdataIds, 1); if (newMenuEntityList != null && newMenuEntityList.Count > 0) { //2、先找栏目,栏目没有就新建一个 AppMenuSettingBLL settingBLL = new AppMenuSettingBLL(); AppMenuSettingEntity menusetting = settingBLL.GetList(param.departId, 0, 1).FirstOrDefault(); string menusettingId = Guid.NewGuid().ToString(); string menusettingName = string.Empty; if (menusetting == null) { menusetting = new AppMenuSettingEntity(); menusetting.DeptCode = param.departCode; menusetting.DeptId = param.departId; menusetting.DeptName = param.departName; menusetting.PlatformType = 1; menusetting.Name = "总栏目"; menusetting.Sort = 1; menusetting.ThemeCode = 0; menusetting.Id = menusettingId; menusettingName = menusetting.Name; settingBLL.SaveForm(null, menusetting); } else { menusettingId = menusetting.Id; menusettingName = menusetting.Name; } //建立栏目与菜单的关联关系 List <AppSettingAssociationEntity> associationEntities = new List <AppSettingAssociationEntity>(); newMenuEntityList.ForEach(x => { associationEntities.Add(new AppSettingAssociationEntity() { ColumnId = menusettingId, ColumnName = menusettingName, DeptId = param.departId, Id = Guid.NewGuid().ToString(), ModuleId = x.ModuleId, Sort = x.Sort, }); }); new AppSettingAssociationBLL().SaveList(associationEntities); } MenuAuthorizeEntity menuAuthorize = authorizeBLL.GetEntityByDeptId(param.departId); if (menuAuthorize != null) { authorizeBLL.SaveForm(menuAuthorize.Id, menuAuthorize);//此处单纯的改变一下版本号 } return(Success("操作成功。")); } catch (Exception ex) { return(Error("操作失败:" + ex.Message)); } }
/// <summary> /// 保存表单 /// </summary> /// <param name="keyValue"></param> /// <param name="entity"></param> /// <returns></returns> public ActionResult SaveForm(string keyValue, MenuAuthorizeEntity entity) { authorizeBLL.SaveForm(keyValue, entity); return(Success("操作成功。")); }
/// <summary> /// 保存 /// </summary> /// <param name="keyValue"></param> /// <param name="entity"></param> public void SaveForm(string keyValue, MenuAuthorizeEntity entity) { service.SaveForm(keyValue, entity); }