implemented sharing of bookmarks
This commit is contained in:
@@ -17,6 +17,7 @@ import de.srsoftware.umbrella.core.model.Bookmark;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -98,7 +99,7 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bookmark save(String url, String comment, long userId) {
|
||||
public Bookmark save(String url, String comment, Collection<Long> userIds) {
|
||||
try {
|
||||
var timestamp = LocalDateTime.now();
|
||||
var rs = select(ID).from(TABLE_URLS).where(URL, equal(url)).exec(db);
|
||||
@@ -112,9 +113,9 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
rs.close();
|
||||
stmt.close();
|
||||
}
|
||||
replaceInto(TABLE_URL_COMMENTS,URL_ID,USER_ID,COMMENT, TIMESTAMP)
|
||||
.values(id,userId,comment,timestamp.toEpochSecond(UTC))
|
||||
.execute(db).close();
|
||||
var query = replaceInto(TABLE_URL_COMMENTS,URL_ID,USER_ID,COMMENT, TIMESTAMP);
|
||||
for (long userId : userIds) query.values(id,userId,comment,timestamp.toEpochSecond(UTC));
|
||||
query.execute(db).close();
|
||||
return Bookmark.of(id,url,comment,timestamp);
|
||||
} catch (SQLException e) {
|
||||
throw new UmbrellaException("Failed to store url");
|
||||
|
||||
Reference in New Issue
Block a user