From be81ccc5427b7fa648050d7d4568eb337f6f9086 Mon Sep 17 00:00:00 2001 From: peterpan Date: Sun, 28 Sep 2025 16:12:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=87=E6=8D=A2jdk=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- new-math-cli.iml | 2 +- src/Main.java | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 8573553..476ce71 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/new-math-cli.iml b/new-math-cli.iml index c90834f..a4929a8 100644 --- a/new-math-cli.iml +++ b/new-math-cli.iml @@ -1,6 +1,6 @@ - + diff --git a/src/Main.java b/src/Main.java index 568a95a..12f9336 100644 --- a/src/Main.java +++ b/src/Main.java @@ -34,14 +34,14 @@ public class Main { String[] input = line.split(" "); if (input.length == 2) { - authService.login(input[0], input[1]).ifPresentOrElse( - user -> { - currentUser = user; - currentLevel = user.getLevel(); - System.out.printf("当前选择为%s出题%n", currentLevel.getName()); - }, - () -> System.out.println("请输入正确的用户名、密码") - ); + User user = authService.login(input[0], input[1]).orElse(null); + if (user != null) { + currentUser = user; + currentLevel = user.getLevel(); + System.out.printf("当前选择为%s出题%n", currentLevel.getName()); + } else { + System.out.println("请输入正确的用户名、密码"); + } } else { System.out.println("输入格式不正确,请重新输入。"); }