aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r--src/main/java/com/juick/service/MessagesService.java5
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java17
-rw-r--r--src/main/java/com/juick/service/TelegramServiceImpl.java1
3 files changed, 12 insertions, 11 deletions
diff --git a/src/main/java/com/juick/service/MessagesService.java b/src/main/java/com/juick/service/MessagesService.java
index b29337b2..8f8c3e62 100644
--- a/src/main/java/com/juick/service/MessagesService.java
+++ b/src/main/java/com/juick/service/MessagesService.java
@@ -141,6 +141,7 @@ public interface MessagesService {
boolean deleteReply(URI userUri, URI replyUri);
- String getMessageProperty(Integer mid, String key);
- void setMessageProperty(Integer mid, String key, String value);
+ String getMessageProperty(Integer mid, Integer rid, String key);
+
+ void setMessageProperty(Integer mid, Integer rid, 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 2bae04e6..798502b3 100644
--- a/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -1186,10 +1186,10 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Transactional(readOnly = true)
@Override
- public String getMessageProperty(Integer mid, String key) {
+ public String getMessageProperty(Integer mid, Integer rid, String key) {
List<String> results = jdbcTemplate.queryForList(
- "SELECT property_value FROM messages_properties WHERE message_id=? AND property_key=?",
- String.class, mid, key);
+ "SELECT property_value FROM messages_properties WHERE message_id=? AND reply_id=? AND property_key=?",
+ String.class, mid, rid, key);
if (results.size() > 0) {
return results.get(0);
}
@@ -1198,22 +1198,23 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Transactional
@Override
- public void setMessageProperty(Integer mid, String key, String value) {
+ public void setMessageProperty(Integer mid, Integer rid, String key, String value) {
SqlParameterSource parameterSource = new MapSqlParameterSource()
.addValue("mid", mid)
+ .addValue("rid", rid)
.addValue("key", key)
.addValue("value", value);
if (StringUtils.isNotEmpty(value)) {
try {
- getNamedParameterJdbcTemplate().update("INSERT INTO messages_properties(message_id, property_key, property_value) " +
- "VALUES(:mid, :key, :value)", parameterSource);
+ getNamedParameterJdbcTemplate().update("INSERT INTO messages_properties(message_id, reply_id, property_key, property_value) " +
+ "VALUES(:mid, :rid, :key, :value)", parameterSource);
} catch (DataIntegrityViolationException ex) {
getNamedParameterJdbcTemplate().update("UPDATE messages_properties SET property_value=:value " +
- "WHERE message_id=:mid AND property_key=:key", parameterSource);
+ "WHERE message_id=:mid AND reply_id=:rid AND property_key=:key", parameterSource);
}
} else {
getNamedParameterJdbcTemplate().update("DELETE FROM messages_properties " +
- "WHERE message_id=:mid AND property_key=:key", parameterSource);
+ "WHERE message_id=:mid AND reply_id=:rid AND property_key=:key", parameterSource);
}
}
}
diff --git a/src/main/java/com/juick/service/TelegramServiceImpl.java b/src/main/java/com/juick/service/TelegramServiceImpl.java
index 99cbabf6..8fb13838 100644
--- a/src/main/java/com/juick/service/TelegramServiceImpl.java
+++ b/src/main/java/com/juick/service/TelegramServiceImpl.java
@@ -18,7 +18,6 @@
package com.juick.service;
import com.juick.User;
-import org.springframework.dao.DuplicateKeyException;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;