1.1 --- a/src/main/java/de/uapcore/lightpit/dao/UserDao.java Sat May 09 15:19:21 2020 +0200 1.2 +++ b/src/main/java/de/uapcore/lightpit/dao/UserDao.java Sat May 09 17:01:29 2020 +0200 1.3 @@ -1,8 +1,8 @@ 1.4 /* 1.5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 1.6 - * 1.7 + * 1.8 * Copyright 2018 Mike Becker. All rights reserved. 1.9 - * 1.10 + * 1.11 * Redistribution and use in source and binary forms, with or without 1.12 * modification, are permitted provided that the following conditions are met: 1.13 * 1.14 @@ -30,50 +30,6 @@ 1.15 1.16 import de.uapcore.lightpit.entities.User; 1.17 1.18 -import java.sql.Connection; 1.19 -import java.sql.ResultSet; 1.20 -import java.sql.SQLException; 1.21 -import java.sql.Statement; 1.22 -import java.util.ArrayList; 1.23 -import java.util.List; 1.24 +public interface UserDao extends GenericDao<User> { 1.25 1.26 -public class UserDao { 1.27 - 1.28 - /** 1.29 - * Maps SQL columns to POJO fields. 1.30 - * 1.31 - * @param result the database result set 1.32 - * @param user the POJO 1.33 - * @throws SQLException on any kind of SQL errors 1.34 - */ 1.35 - protected void mapColumns(ResultSet result, User user) throws SQLException { 1.36 - user.setUserID(result.getInt("userid")); 1.37 - user.setUsername(result.getString("username")); 1.38 - user.setGivenname(result.getString("givenname")); 1.39 - user.setLastname(result.getString("lastname")); 1.40 - } 1.41 - 1.42 - /** 1.43 - * Returns a list of all users ordered by their username. 1.44 - * <p> 1.45 - * Does not return reserved system users with negative user IDs. 1.46 - * 1.47 - * @param conn the connection to use 1.48 - * @return a list of all users 1.49 - * @throws SQLException on any kind of SQL errors 1.50 - */ 1.51 - public List<User> listAll(Connection conn) throws SQLException { 1.52 - List<User> list = new ArrayList<>(); 1.53 - try ( 1.54 - Statement stmt = conn.createStatement(); 1.55 - ResultSet result = stmt.executeQuery( 1.56 - "SELECT * FROM lpitcore_user WHERE userid >= 0 ORDER BY username")) { 1.57 - while (result.next()) { 1.58 - final User user = new User(); 1.59 - mapColumns(result, user); 1.60 - list.add(user); 1.61 - } 1.62 - } 1.63 - return list; 1.64 - } 1.65 }