implemented bookmark search
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
package de.srsoftware.umbrella.bookmarks;
|
||||
|
||||
import static de.srsoftware.tools.jdbc.Condition.equal;
|
||||
import static de.srsoftware.tools.jdbc.Condition.like;
|
||||
import static de.srsoftware.tools.jdbc.Query.*;
|
||||
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
|
||||
import static de.srsoftware.umbrella.bookmarks.Constants.*;
|
||||
@@ -69,7 +70,26 @@ CREATE TABLE IF NOT EXISTS {0} (
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Bookmark> list(long userId, long offset, long limit) {
|
||||
public Map<Long, Bookmark> find(long userId, Collection<String> keys) {
|
||||
try {
|
||||
var map = new HashMap<Long,Bookmark>();
|
||||
var query = select(ALL).from(TABLE_URL_COMMENTS).leftJoin(URL_ID,TABLE_URLS,ID)
|
||||
.where(USER_ID, equal(userId));
|
||||
for (var key : keys) query.where(COMMENT,like("%"+key+"%"));
|
||||
var rs = query.sort(format("{0} DESC",TIMESTAMP)).exec(db);
|
||||
while (rs.next()){
|
||||
var bookmark = Bookmark.of(rs);
|
||||
map.put(bookmark.urlId(),bookmark);
|
||||
}
|
||||
rs.close();;
|
||||
return map;
|
||||
} catch (SQLException e) {
|
||||
throw new UmbrellaException("Failed to load bookmark list");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Bookmark> list(long userId, Long offset, Long limit) {
|
||||
try {
|
||||
var map = new HashMap<Long,Bookmark>();
|
||||
var rs = select(ALL).from(TABLE_URL_COMMENTS).leftJoin(URL_ID,TABLE_URLS,ID).where(USER_ID, equal(userId)).sort(format("{0} DESC",TIMESTAMP)).skip(offset).limit(limit).exec(db);
|
||||
|
||||
Reference in New Issue
Block a user