创建群时同步操作
This commit is contained in:
@@ -1039,78 +1039,76 @@ public class DatabaseStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void persistGroupInfo(final WFCMessage.GroupInfo groupInfo) {
|
void persistGroupInfo(final WFCMessage.GroupInfo groupInfo) {
|
||||||
mScheduler.execute(()->{
|
Connection connection = null;
|
||||||
Connection connection = null;
|
PreparedStatement statement = null;
|
||||||
PreparedStatement statement = null;
|
try {
|
||||||
try {
|
connection = DBUtil.getConnection();
|
||||||
connection = DBUtil.getConnection();
|
String sql = "insert into t_group (`_gid`" +
|
||||||
String sql = "insert into t_group (`_gid`" +
|
", `_name`" +
|
||||||
", `_name`" +
|
", `_portrait`" +
|
||||||
", `_portrait`" +
|
", `_owner`" +
|
||||||
", `_owner`" +
|
", `_type`" +
|
||||||
", `_type`" +
|
", `_extra`" +
|
||||||
", `_extra`" +
|
", `_dt`" +
|
||||||
", `_dt`" +
|
", `_member_count`" +
|
||||||
", `_member_count`" +
|
", `_mute`" +
|
||||||
", `_mute`" +
|
", `_join_type`" +
|
||||||
", `_join_type`" +
|
", `_private_chat`" +
|
||||||
", `_private_chat`" +
|
", `_searchable`" +
|
||||||
", `_searchable`" +
|
", `_member_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||||
", `_member_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
" ON DUPLICATE KEY UPDATE " +
|
||||||
" ON DUPLICATE KEY UPDATE " +
|
"`_name` = ?," +
|
||||||
"`_name` = ?," +
|
"`_portrait` = ?," +
|
||||||
"`_portrait` = ?," +
|
"`_owner` = ?," +
|
||||||
"`_owner` = ?," +
|
"`_type` = ?," +
|
||||||
"`_type` = ?," +
|
"`_extra` = ?," +
|
||||||
"`_extra` = ?," +
|
"`_dt` = ?," +
|
||||||
"`_dt` = ?," +
|
"`_member_count` = ?," +
|
||||||
"`_member_count` = ?," +
|
"`_mute` = ?" +
|
||||||
"`_mute` = ?" +
|
", `_join_type` = ?" +
|
||||||
", `_join_type` = ?" +
|
", `_private_chat` = ?" +
|
||||||
", `_private_chat` = ?" +
|
", `_searchable` = ?, " +
|
||||||
", `_searchable` = ?, " +
|
"`_member_dt` = ?";
|
||||||
"`_member_dt` = ?";
|
|
||||||
|
|
||||||
|
|
||||||
statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
|
|
||||||
int index = 1;
|
int index = 1;
|
||||||
statement.setString(index++, groupInfo.getTargetId());
|
statement.setString(index++, groupInfo.getTargetId());
|
||||||
statement.setString(index++, groupInfo.getName());
|
statement.setString(index++, groupInfo.getName());
|
||||||
statement.setString(index++, groupInfo.getPortrait());
|
statement.setString(index++, groupInfo.getPortrait());
|
||||||
statement.setString(index++, groupInfo.getOwner());
|
statement.setString(index++, groupInfo.getOwner());
|
||||||
statement.setInt(index++, groupInfo.getType());
|
statement.setInt(index++, groupInfo.getType());
|
||||||
statement.setString(index++, groupInfo.getExtra());
|
statement.setString(index++, groupInfo.getExtra());
|
||||||
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||||
statement.setInt(index++, groupInfo.getMemberCount());
|
statement.setInt(index++, groupInfo.getMemberCount());
|
||||||
statement.setInt(index++, groupInfo.getMute());
|
statement.setInt(index++, groupInfo.getMute());
|
||||||
statement.setInt(index++, groupInfo.getJoinType());
|
statement.setInt(index++, groupInfo.getJoinType());
|
||||||
statement.setInt(index++, groupInfo.getPrivateChat());
|
statement.setInt(index++, groupInfo.getPrivateChat());
|
||||||
statement.setInt(index++, groupInfo.getSearchable());
|
statement.setInt(index++, groupInfo.getSearchable());
|
||||||
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||||
|
|
||||||
statement.setString(index++, groupInfo.getName());
|
statement.setString(index++, groupInfo.getName());
|
||||||
statement.setString(index++, groupInfo.getPortrait());
|
statement.setString(index++, groupInfo.getPortrait());
|
||||||
statement.setString(index++, groupInfo.getOwner());
|
statement.setString(index++, groupInfo.getOwner());
|
||||||
statement.setInt(index++, groupInfo.getType());
|
statement.setInt(index++, groupInfo.getType());
|
||||||
statement.setString(index++, groupInfo.getExtra());
|
statement.setString(index++, groupInfo.getExtra());
|
||||||
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||||
statement.setInt(index++, groupInfo.getMemberCount());
|
statement.setInt(index++, groupInfo.getMemberCount());
|
||||||
statement.setInt(index++, groupInfo.getMute());
|
statement.setInt(index++, groupInfo.getMute());
|
||||||
statement.setInt(index++, groupInfo.getJoinType());
|
statement.setInt(index++, groupInfo.getJoinType());
|
||||||
statement.setInt(index++, groupInfo.getPrivateChat());
|
statement.setInt(index++, groupInfo.getPrivateChat());
|
||||||
statement.setInt(index++, groupInfo.getSearchable());
|
statement.setInt(index++, groupInfo.getSearchable());
|
||||||
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||||
int count = statement.executeUpdate();
|
int count = statement.executeUpdate();
|
||||||
LOG.info("Update rows {}", count);
|
LOG.info("Update rows {}", count);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Utility.printExecption(LOG, e);
|
Utility.printExecption(LOG, e);
|
||||||
} finally {
|
} finally {
|
||||||
DBUtil.closeDB(connection, statement);
|
DBUtil.closeDB(connection, statement);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MemorySessionStore.Session> getUserActivedSessions(String uid) {
|
List<MemorySessionStore.Session> getUserActivedSessions(String uid) {
|
||||||
@@ -1560,39 +1558,37 @@ public class DatabaseStore {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
void updateGroupMemberCountDt(final String groupId, final int count, final long dt) {
|
void updateGroupMemberCountDt(final String groupId, final int count, final long dt) {
|
||||||
mScheduler.execute(()->{
|
Connection connection = null;
|
||||||
Connection connection = null;
|
PreparedStatement statement = null;
|
||||||
PreparedStatement statement = null;
|
try {
|
||||||
try {
|
connection = DBUtil.getConnection();
|
||||||
connection = DBUtil.getConnection();
|
|
||||||
|
|
||||||
String sql ;
|
String sql ;
|
||||||
|
|
||||||
if (count >= 0) {
|
if (count >= 0) {
|
||||||
sql = "update t_group set `_member_count` = ?, `_member_dt` = ? , `_dt` = ? where `_gid` = ?";
|
sql = "update t_group set `_member_count` = ?, `_member_dt` = ? , `_dt` = ? where `_gid` = ?";
|
||||||
} else {
|
} else {
|
||||||
sql = "update t_group set `_member_dt` = ?, `_dt` = ? where `_gid` = ?";
|
sql = "update t_group set `_member_dt` = ?, `_dt` = ? where `_gid` = ?";
|
||||||
}
|
|
||||||
statement = connection.prepareStatement(sql);
|
|
||||||
|
|
||||||
int index = 1;
|
|
||||||
if (count >=0) {
|
|
||||||
statement.setInt(index++, count);
|
|
||||||
}
|
|
||||||
statement.setLong(index++, dt);
|
|
||||||
statement.setLong(index++, dt);
|
|
||||||
statement.setString(index++, groupId);
|
|
||||||
|
|
||||||
int c = statement.executeUpdate();
|
|
||||||
LOG.info("Update rows {}", c);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
Utility.printExecption(LOG, e);
|
|
||||||
} finally {
|
|
||||||
DBUtil.closeDB(connection, statement);
|
|
||||||
}
|
}
|
||||||
});
|
statement = connection.prepareStatement(sql);
|
||||||
|
|
||||||
|
int index = 1;
|
||||||
|
if (count >=0) {
|
||||||
|
statement.setInt(index++, count);
|
||||||
|
}
|
||||||
|
statement.setLong(index++, dt);
|
||||||
|
statement.setLong(index++, dt);
|
||||||
|
statement.setString(index++, groupId);
|
||||||
|
|
||||||
|
int c = statement.executeUpdate();
|
||||||
|
LOG.info("Update rows {}", c);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
Utility.printExecption(LOG, e);
|
||||||
|
} finally {
|
||||||
|
DBUtil.closeDB(connection, statement);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void persistGroupMember(final String groupId, final List<WFCMessage.GroupMember> memberList) {
|
void persistGroupMember(final String groupId, final List<WFCMessage.GroupMember> memberList) {
|
||||||
|
|||||||
Reference in New Issue
Block a user