diff options
Diffstat (limited to 'src/main/java/com/juick/service')
-rw-r--r-- | src/main/java/com/juick/service/MessagesService.java | 1 | ||||
-rw-r--r-- | src/main/java/com/juick/service/MessagesServiceImpl.java | 12 |
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(); + } } |