public JsonResult FunctionDelete(string id) { SysPower.Delete("where function_id in (@0)", id.ToIntList()); SysFunction.Delete("where id in (@0)", id.ToIntList()); return(Json(ArtDialogResponseResult.SuccessResult)); }
public JsonResult Authorize(string functionIds, int id) { var role = SysRole.SingleOrDefault(id); // 删除权限 SysPower.Delete("where master_id in (@0) and master_type=@1", role.ID, MasterType.Role.ToString()); // 角色授权 if (string.IsNullOrEmpty(functionIds) == false) { var funcs = SysFunction.Fetch("where id in (@0)", functionIds.ToIntList()); foreach (var func in funcs) { SysPower power = new SysPower { FunctionID = func.ID, MasterID = role.ID, MasterType = MasterType.Role.ToString() }; power.Insert(); } } // 刷新用户权限 var users = SysUser.Fetch("where role_id=@0", role.ID); foreach (var user in users) { SysPower.Delete("where master_id in (@0) and master_type=@1", user.ID, MasterType.User.ToString()); var powers = SysPower.Fetch("where master_id=@0 and master_type=@1", user.RoleID, MasterType.Role.ToString()); foreach (var power in powers) { try { SysPower newPower = new SysPower { FunctionID = power.FunctionID, MasterID = user.ID, MasterType = MasterType.User.ToString() }; newPower.Insert(); } catch { } } } return(Json(ArtDialogResponseResult.SuccessResult)); }