implemented loading of accounts
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -3,13 +3,19 @@ package de.srsoftware.umbrella.core.model;
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import de.srsoftware.umbrella.core.constants.Field;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
|
||||
|
||||
public record Account(long id, String name, String currency, long ownerId) implements Mappable {
|
||||
public Account withId(long newId) {
|
||||
return new Account(newId,name,currency,ownerId);
|
||||
public static Account of(ResultSet rs) throws SQLException {
|
||||
var id = rs.getLong(Field.ID);
|
||||
var name = rs.getString(Field.NAME);
|
||||
var owner = rs.getLong(Field.OWNER);
|
||||
var currency = rs.getString(Field.CURRENCY);
|
||||
return new Account(id,name,currency,owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,4 +28,8 @@ public record Account(long id, String name, String currency, long ownerId) imple
|
||||
Field.OWNER, owner.toMap()
|
||||
);
|
||||
}
|
||||
|
||||
public Account withId(long newId) {
|
||||
return new Account(newId,name,currency,ownerId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user