Skip to content

Commit

Permalink
Update User.java
Browse files Browse the repository at this point in the history
  • Loading branch information
410-dev committed Jan 15, 2023
1 parent 68967dd commit 7d75b40
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
import lombok.Getter;
import lombok.Setter;
import me.hy.libhycore.CoreSHA;
import me.hy.libhyextended.mail.HEMail;
import me.hy.libhyextended.mail.servers.HEGmail;
import me.hy.libhyextended.objects.DatabaseObject;
import me.hy.libhyextended.objects.exception.DataFieldMismatchException;
import me.hy.libhyextended.objects.exception.UndefinedSQLKeyException;
import me.hy.libhyextended.sql.SQLConnection;
import org.mcmasterkboys.codenamehenryford.modules.SQLConnectionFactory;
import org.mcmasterkboys.codenamehenryford.objects.banking.BankAccount;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;


@Getter
Expand Down Expand Up @@ -72,4 +74,20 @@ public String hashPassword(String password) {
public void sendVerificationCode() {
// TODO: Send verification code to user's email
}

public BankAccount[] getBankAccounts() throws SQLException, DataFieldMismatchException, UndefinedSQLKeyException {
ArrayList<BankAccount> bankAccounts = new ArrayList<>();

SQLConnection sqlConnection = new SQLConnectionFactory().getConnection();
ResultSet rs = sqlConnection.executeQuery("SELECT * FROM bank_accounts WHERE ownerUUID = ?", this.uuid);
while (rs.next()) {
BankAccount bankAccount = new BankAccount();
bankAccount.mapFromResultSet(rs);
bankAccounts.add(bankAccount);
}
rs.close();
sqlConnection.close();

return bankAccounts.toArray(new BankAccount[0]);
}
}

0 comments on commit 7d75b40

Please sign in to comment.