overhaule db layout, so we have LONG values as keys
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
package de.srsoftware.umbrella.core.model;
|
||||
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.Util.SHA1;
|
||||
import static de.srsoftware.umbrella.core.Util.sha1;
|
||||
import static java.time.ZoneOffset.UTC;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
@@ -14,22 +12,22 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public record Bookmark(String url, Hash hash, String comment, LocalDateTime timestamp, Collection<String> tags) implements Mappable {
|
||||
public record Bookmark(long id, String url, String comment, LocalDateTime timestamp, Collection<String> tags) implements Mappable {
|
||||
|
||||
public static Bookmark of(ResultSet rs) throws SQLException {
|
||||
return new Bookmark(rs.getString(URL),new Hash(rs.getString(HASH),SHA1),rs.getString(COMMENT),LocalDateTime.ofEpochSecond(rs.getLong(TIMESTAMP),0, UTC),new ArrayList<>());
|
||||
return new Bookmark(rs.getLong(ID),rs.getString(URL),rs.getString(COMMENT),LocalDateTime.ofEpochSecond(rs.getLong(TIMESTAMP),0, UTC),new ArrayList<>());
|
||||
}
|
||||
|
||||
public static Bookmark of(String url, String comment, LocalDateTime timestamp){
|
||||
return new Bookmark(url,sha1(url),comment,timestamp,new ArrayList<>());
|
||||
public static Bookmark of(long id, String url, String comment, LocalDateTime timestamp){
|
||||
return new Bookmark(id,url,comment,timestamp,new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
return Map.of(
|
||||
ID,id,
|
||||
URL, url,
|
||||
COMMENT, comment,
|
||||
HASH, Map.of(VALUE,hash.value(),TYPE,hash.type()),
|
||||
TAGS, tags,
|
||||
TIMESTAMP, timestamp.withNano(0)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user