friend alias

This commit is contained in:
heavyrain.lee
2019-05-02 21:43:01 +08:00
parent 0cbb9fd1a4
commit ab3882e1d4
6 changed files with 107 additions and 14 deletions
@@ -272,7 +272,7 @@ public class DatabaseStore {
try {
connection = DBUtil.getConnection();
String sql = "select `_uid`, `_friend_uid`, `_state`, `_dt` from t_friend";
String sql = "select `_uid`, `_friend_uid`, `_alias`, `_state`, `_dt` from t_friend";
statement = connection.prepareStatement(sql);
int index;
@@ -290,6 +290,9 @@ public class DatabaseStore {
value = (value == null ? "" : value);
builder.setFriendUid(value);
value = rs.getString(index++);
value = (value == null ? "" : value);
builder.setAlias(value);
int intvalue = rs.getInt(index++);
builder.setState(intvalue);
@@ -1777,7 +1780,7 @@ public class DatabaseStore {
ResultSet rs = null;
try {
connection = DBUtil.getConnection();
String sql = "select `_friend_uid`, `_state`, `_dt` from t_friend where `_uid` = ?";
String sql = "select `_friend_uid`, `_alias`, `_state`, `_dt` from t_friend where `_uid` = ?";
statement = connection.prepareStatement(sql);
@@ -1789,10 +1792,11 @@ public class DatabaseStore {
List<FriendData> out = new ArrayList<>();
while (rs.next()) {
String uid = rs.getString(1);
int state = rs.getInt(2);
long timestamp = rs.getLong(3);
String alias = rs.getString(2);
int state = rs.getInt(3);
long timestamp = rs.getLong(4);
FriendData data = new FriendData(userId, uid, state, timestamp);
FriendData data = new FriendData(userId, uid, alias, state, timestamp);
out.add(data);
}
return out;
@@ -1947,8 +1951,9 @@ public class DatabaseStore {
PreparedStatement statement = null;
try {
connection = DBUtil.getConnection();
String sql = "insert into t_friend (`_uid`, `_friend_uid`, `_state`, `_dt`) values(?, ?, ?, ?)" +
String sql = "insert into t_friend (`_uid`, `_friend_uid`, `_alias`, `_state`, `_dt`) values(?, ?, ?, ?, ?)" +
" ON DUPLICATE KEY UPDATE " +
"`_alias` = ?," +
"`_state` = ?," +
"`_dt` = ?";
@@ -1957,8 +1962,10 @@ public class DatabaseStore {
int index = 1;
statement.setString(index++, request.getUserId());
statement.setString(index++, request.getFriendUid());
statement.setString(index++, request.getAlias());
statement.setInt(index++, request.getState());
statement.setLong(index++, request.getTimestamp());
statement.setString(index++, request.getAlias());
statement.setInt(index++, request.getState());
statement.setLong(index++, request.getTimestamp());
int count = statement.executeUpdate();