public IActionResult DelAdminRole(int id) { AdminRoles entity = AdminRoles.Find(AdminRoles._.Id == id); if (entity == null) { tip.Message = "系统找不到本管理组详情!"; return(Json(tip)); } if (entity.NotAllowDel == 1) { tip.Message = "本管理组设定不允许删除,如果需要删除,请先解除限制!"; return(Json(tip)); } //如果不是超级管理员,不允许删除 Core.Admin my = Core.Admin.GetMyInfo(); if (my.Roles.IsSuperAdmin != 1) { tip.Message = "非超级管理员,不能执行此操作!"; return(Json(tip)); } //如果只有一个管理组,不允许删除! if (AdminRoles.FindCount(null, null, null, 0, 0) == 1) { tip.Message = "只有一个管理组,不能删除!"; return(Json(tip)); } //删除管理组,并删除旗下所有管理员 Core.Admin.WriteLogActions($"执行删除管理组({entity.Id}:{entity.RoleName})详情;"); entity.Delete(); tip.Status = JsonTip.SUCCESS; tip.Message = "删除管理组成功"; return(Json(tip)); }
/// <summary>已重载。在事务保护范围内处理业务,位于Valid之后</summary> /// <returns></returns> protected override int OnUpdate() { //是否修改了角色ID串 if (Dirtys[__.RoleIDs]) { //先删除关联 if (AdminRoles != null) { AdminRoles.Delete(); } //再插入关联 InsertAdminRole(); } return(base.OnUpdate()); }
/// <summary>已重载。删除关联数据</summary> /// <returns></returns> protected override int OnDelete() { if (AdminRoles != null) { AdminRoles.Delete(); } if (RoleDataPermissions != null) { RoleDataPermissions.Delete(); } if (RoleMenus != null) { RoleMenus.Delete(); } if (RoleMenuButtons != null) { RoleMenuButtons.Delete(); } return(base.OnDelete()); }