aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-04-07 03:49:09 +0300
committerGravatar Vitaly Takmazov2019-04-07 03:49:09 +0300
commitf1278ae7119fcb77326c6d520915ecaa1527d39c (patch)
tree3d0c5eac7cef2c3e08ab9f5260f2f0dfc14d4532 /src/main/java/com/juick/service
parent97b37acdaee5d1665c2393254bc764bb4562729c (diff)
Edit telegram messages
Diffstat (limited to 'src/main/java/com/juick/service')
-rw-r--r--src/main/java/com/juick/service/MessagesService.java1
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java12
2 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/com/juick/service/MessagesService.java b/src/main/java/com/juick/service/MessagesService.java
index 8f8c3e62..e98b2b1d 100644
--- a/src/main/java/com/juick/service/MessagesService.java
+++ b/src/main/java/com/juick/service/MessagesService.java
@@ -144,4 +144,5 @@ public interface MessagesService {
String getMessageProperty(Integer mid, Integer rid, String key);
void setMessageProperty(Integer mid, Integer rid, String key, String value);
+ Optional<Pair<Integer, Integer>> findMessageByProperty(String key, String value);
}
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java
index 798502b3..0cf321b6 100644
--- a/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -1217,4 +1217,16 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
"WHERE message_id=:mid AND reply_id=:rid AND property_key=:key", parameterSource);
}
}
+
+ @Transactional(readOnly = true)
+ @Override
+ public Optional<Pair<Integer, Integer>> findMessageByProperty(String key, String value) {
+ List<Pair<Integer, Integer>> results = jdbcTemplate.query("SELECT message_id, reply_id FROM messages_properties " +
+ "WHERE property_key=? AND property_value=?",
+ (rs, rowNum) -> Pair.of(rs.getInt(1), rs.getInt(2)), key, value);
+ if (results.size() > 0) {
+ return Optional.of(results.get(0));
+ }
+ return Optional.empty();
+ }
}