public ActionResult ConfigAuth(int id) { RoleAuthModel model = new RoleAuthModel(); IPropertyRoleBLL propertyRoleBll = BLLFactory <IPropertyRoleBLL> .GetBLL("PropertyRoleBLL"); //获取要分配角色的物业角色 T_PropertyRole role = propertyRoleBll.GetEntity(m => m.Id == id); IMenuBLL menuBll = BLLFactory <IMenuBLL> .GetBLL("MenuBLL"); //获取所有的菜单 var menuList = menuBll.GetList(m => m.MenuFlag == ConstantParam.MENU_LEFT && m.IsPlatform == ConstantParam.USER_TYPE_PROPERTY && m.ParentId == null).OrderBy(m => m.Order).ToList(); //Model赋值菜单列表 model.MenuList = menuList; //Model赋值要分配角色的物业角色 model.Role = new RoleModel() { RoleId = role.Id, RoleName = role.RoleName, RoleMemo = role.RoleMemo }; //获取该角色已经有的权限ID集合 model.ActionIds = role.PropertyRoleActions.Select(m => m.ActionId).ToList(); return(View(model)); }
public JsonResult DeleteRole(int id) { JsonModel jm = new JsonModel(); IPropertyRoleBLL propertyRoleBll = BLLFactory <IPropertyRoleBLL> .GetBLL("PropertyRoleBLL"); //获取要删除的物业角色 T_PropertyRole role = propertyRoleBll.GetEntity(m => m.Id == id); if (role == null) { jm.Msg = "该角色不存在"; } else if (role.PropertyUserRoles.Count > 0) { jm.Msg = "有配置该角色的用户,不能删除"; } else { if (propertyRoleBll.Delete(role)) { //操作日志 jm.Content = "删除物业角色 " + role.RoleName; } else { jm.Msg = "删除失败"; } } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ActionResult ViewAuth(int id) { RoleAuthModel model = new RoleAuthModel(); IPropertyRoleBLL propertyRoleBll = BLLFactory <IPropertyRoleBLL> .GetBLL("PropertyRoleBLL"); //获取要查看权限的物业角色 T_PropertyRole role = propertyRoleBll.GetEntity(m => m.Id == id); //赋值 要查看权限的物业角色 model.Role = new RoleModel() { RoleId = role.Id, RoleName = role.RoleName, RoleMemo = role.RoleMemo }; //如果是普通角色 if (role.IsSystem == ConstantParam.USER_ROLE_DEFAULT) { //赋值 该角色所有的权限ID集合 model.ActionIds = role.PropertyRoleActions.Select(m => m.ActionId).ToList(); //Model赋值 该角色所关联的非重复菜单 var roleMenuList = role.PropertyRoleActions.Select(m => m.Action.Menu).Distinct().OrderBy(m => m.Order).ToList(); //新定义展示Model树形菜单 var menuList = new List <M_Menu>(); foreach (var menu in roleMenuList) { if (menu.ParentId != null) { if (!menuList.Contains(menu.ParentMenu)) { menuList.Add(menu.ParentMenu); } } menuList.Add(menu); } model.MenuList = menuList; } else { IActionBLL actionBll = BLLFactory <IActionBLL> .GetBLL("ActionBLL"); //赋值 所有的物业权限 model.ActionIds = actionBll.GetList(a => a.Menu.IsPlatform == ConstantParam.USER_TYPE_PROPERTY).Select(a => a.Id).ToList(); IMenuBLL menuBll = BLLFactory <IMenuBLL> .GetBLL("MenuBLL"); //Model赋值 所有的平台菜单 model.MenuList = menuBll.GetList(m => m.IsPlatform == ConstantParam.USER_TYPE_PROPERTY).ToList(); } return(View(model)); }
public JsonResult ConfigAuth(RoleConfigAuthModel model) { JsonModel jm = new JsonModel(); try { IPropertyRoleBLL propertyRoleBll = BLLFactory <IPropertyRoleBLL> .GetBLL("PropertyRoleBLL"); //获取要分配角色的物业角色 T_PropertyRole role = propertyRoleBll.GetEntity(m => m.Id == model.RoleId); List <R_PropertyRoleAction> actions = new List <R_PropertyRoleAction>(); //如果设置了首页权限 51:为物业平台首页权限ID if (model.ids != null && model.ids.Length > 0 && model.ids.Contains(51)) { //没有设置任何权限 则不执行循环操作 foreach (var id in model.ids) { R_PropertyRoleAction item = new R_PropertyRoleAction() { ActionId = id, RoleId = model.RoleId }; actions.Add(item); } //修改角色对应的权限组 if (propertyRoleBll.ConfigAuth(role, actions)) { jm.Content = "物业角色" + role.RoleName + "分配权限"; } else { jm.Msg = "分配权限失败"; } } else { jm.Msg = "必须分配物业平台首页权限"; } } catch { jm.Msg = "分配权限失败"; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 设置管理员提交 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonModel SetAdmin(PropertyUserModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL"); T_PropertyUser propertyUser = new T_PropertyUser() { PropertyPlaceId = model.PlaceId, UserName = model.UserName, Email = model.Email, Password = PropertyUtils.GetMD5Str(model.Password), IsMgr = ConstantParam.USER_ROLE_MGR, DelFlag = ConstantParam.DEL_FLAG_DEFAULT, }; //为管理员添加角色 IPropertyRoleBLL roleBll = BLLFactory <IPropertyRoleBLL> .GetBLL("PropertyRoleBLL"); var role = roleBll.GetEntity(r => r.IsSystem == ConstantParam.USER_ROLE_MGR && r.PropertyPlaceId == model.PlaceId); if (role != null) { propertyUser.PropertyUserRoles.Add(new R_PropertyUserRole() { RoleId = role.Id, }); } //创建管理员 propertyUserBll.Save(propertyUser); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(jm); }
public ActionResult EditRole(int id) { IPropertyRoleBLL propertyRoleBll = BLLFactory <IPropertyRoleBLL> .GetBLL("PropertyRoleBLL"); //获取要编辑的物业角色 T_PropertyRole role = propertyRoleBll.GetEntity(m => m.Id == id); if (role != null) { //初始化返回页面的模型 RoleModel model = new RoleModel() { RoleId = role.Id, RoleName = role.RoleName, RoleMemo = role.RoleMemo }; return(View(model)); } else { return(RedirectToAction("RoleList")); } }
public JsonResult EditRole(RoleModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IPropertyRoleBLL propertyRoleBll = BLLFactory <IPropertyRoleBLL> .GetBLL("PropertyRoleBLL"); T_PropertyRole role = propertyRoleBll.GetEntity(m => m.Id == model.RoleId); if (role != null) { role.RoleName = model.RoleName; role.RoleMemo = model.RoleMemo; //编辑 if (propertyRoleBll.Update(role)) { //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { jm.Msg = "编辑失败"; } } else { jm.Msg = "该角色不存在"; } } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }