Implement database, daos and other classes
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
package dev.ui;
|
||||
|
||||
import dev.model.User;
|
||||
import dev.service.AuthService;
|
||||
import dev.service.MenuService;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class ConsoleMenu {
|
||||
|
||||
private final Scanner scanner =
|
||||
new Scanner(System.in);
|
||||
private final Scanner scanner = new Scanner(System.in);
|
||||
private final AuthService authService = new AuthService();
|
||||
|
||||
public void start() {
|
||||
|
||||
@@ -21,13 +25,42 @@ public class ConsoleMenu {
|
||||
|
||||
switch (choice) {
|
||||
|
||||
case 1:
|
||||
// TODO
|
||||
break;
|
||||
case 1: {
|
||||
System.out.println("Enter username: ");
|
||||
String username = scanner.next();
|
||||
System.out.println("Enter password: ");
|
||||
String password = scanner.next();
|
||||
|
||||
case 2:
|
||||
// TODO
|
||||
User user = authService.login(username, password);
|
||||
|
||||
if (user == null) {
|
||||
System.err.println("Unable to login");
|
||||
continue;
|
||||
}
|
||||
|
||||
System.out.println("welcome! " + user.getUsername());
|
||||
MenuService menuService = new MenuService();
|
||||
menuService.showMenu();
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: {
|
||||
System.out.println("Enter username: ");
|
||||
String username = scanner.nextLine();
|
||||
System.out.println("Enter password: ");
|
||||
String password = scanner.nextLine();
|
||||
System.out.println("Enter email: ");
|
||||
String email = scanner.nextLine();
|
||||
|
||||
if (!authService.register(username, password, email)) {
|
||||
System.err.println("Registration failed.");
|
||||
continue;
|
||||
}
|
||||
|
||||
System.out.println("Registered successfully.");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 3:
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user