[DEBUG] fix the UserDBAccess

This commit is contained in:
Edouard DUPIN 2024-02-03 18:47:30 +01:00
parent 7ae948bb79
commit 1bcdb1df8c

View File

@ -5,6 +5,8 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import org.kar.archidata.dataAccess.DataAccess;
import org.kar.archidata.dataAccess.QueryOption;
import org.kar.archidata.dataAccess.QueryOptions;
import org.kar.archidata.dataAccess.options.DBInterfaceOption;
import org.kar.archidata.db.DBEntry;
import org.kar.archidata.model.User;
@ -13,20 +15,21 @@ public class UserDB {
public UserDB() {}
public static User getUsers(final long userId) throws Exception {
return DataAccess.get(User.class, userId);
public static User getUsers(final long userId, QueryOption... option) throws Exception {
return DataAccess.get(User.class, userId, option);
}
public static User getUserOrCreate(final long userId, final String userLogin) throws Exception {
public static User getUserOrCreate(final long userId, final String userLogin, QueryOption... option) throws Exception {
final User user = getUsers(userId);
if (user != null) {
return user;
}
createUsersInfoFromOAuth(userId, userLogin);
createUsersInfoFromOAuth(userId, userLogin, option);
return getUsers(userId);
}
private static void createUsersInfoFromOAuth(final long userId, final String login) throws IOException {
private static void createUsersInfoFromOAuth(final long userId, final String login, QueryOption... option) throws IOException {
QueryOptions options = new QueryOptions(option);
final DBEntry entry = DBInterfaceOption.getAutoEntry(options);
final String query = "INSERT INTO `user` (`id`, `login`, `lastConnection`, `admin`, `blocked`, `removed`) VALUE (?,?,now(3),'0','0','0')";
try {