Search in sources :

Example 11 with SimpleUserBean

use of com.akaxin.site.storage.bean.SimpleUserBean in project openzaly by akaxincom.

the class GroupNotice method newGroupMemberNotice.

/**
 * 新用户加入了群聊 <br>
 * eg:群聊天界面中,<张三 加入了群聊天>
 */
public void newGroupMemberNotice(String siteUserId, String groupId, List<String> userIdList) {
    if (StringUtils.isAnyEmpty(siteUserId, groupId) || userIdList == null || userIdList.size() == 0) {
        return;
    }
    StringBuilder noticeText = new StringBuilder();
    try {
        // 移除群主,群创建者
        userIdList.remove(siteUserId);
        // 查询群主信息
        SimpleUserBean bean = UserProfileDao.getInstance().getSimpleProfileById(siteUserId);
        if (bean != null && StringUtils.isNotEmpty(bean.getUserName())) {
            noticeText.append(bean.getUserName());
            noticeText.append(" 邀请了 ");
        }
        int num = 0;
        for (String userId : userIdList) {
            SimpleUserBean memberBean = UserProfileDao.getInstance().getSimpleProfileById(userId);
            if (memberBean != null && StringUtils.isNotEmpty(memberBean.getUserName())) {
                noticeText.append(memberBean.getUserName());
                if (num++ < (userIdList.size() - 1)) {
                    noticeText.append(",");
                }
            }
        }
        noticeText.append(NoticeText.USER_ADD_GROUP);
        this.groupMsgNotice(siteUserId, groupId, noticeText.toString());
    } catch (Exception e) {
        logger.error("new group member notice error. notice=" + noticeText.toString(), e);
    }
}
Also used : ByteString(com.google.protobuf.ByteString) SimpleUserBean(com.akaxin.site.storage.bean.SimpleUserBean)

Example 12 with SimpleUserBean

use of com.akaxin.site.storage.bean.SimpleUserBean in project openzaly by akaxincom.

the class SQLiteUserGroupDao method queryUserFriendNonGroupMemberList.

/**
 * 查询用户好友中非群成员用户
 *
 * @param groupId
 * @param pageNum
 * @param pageSize
 * @return
 * @throws SQLException
 */
public List<SimpleUserBean> queryUserFriendNonGroupMemberList(String siteUserId, String groupId, int pageNum, int pageSize) throws SQLException {
    long startTime = System.currentTimeMillis();
    List<SimpleUserBean> userList = new ArrayList<SimpleUserBean>();
    int startNum = (pageNum - 1) * pageSize;
    String sql = "SELECT a.site_friend_id,b.user_name,b.user_photo FROM " + SQLConst.SITE_USER_FRIEND + " AS a LEFT JOIN " + SQLConst.SITE_USER_PROFILE + " AS b WHERE a.site_friend_id=b.site_user_id AND a.site_user_id=? AND a.site_friend_id NOT IN (SELECT DISTINCT site_user_id FROM " + SQLConst.SITE_USER_GROUP + " WHERE site_group_id=?) LIMIT ?,?;";
    PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
    preStatement.setString(1, siteUserId);
    preStatement.setString(2, groupId);
    preStatement.setInt(3, startNum);
    preStatement.setInt(4, pageSize);
    ResultSet rs = preStatement.executeQuery();
    while (rs.next()) {
        SimpleUserBean userBean = new SimpleUserBean();
        userBean.setUserId(rs.getString(1));
        userBean.setUserName(rs.getString(2));
        userBean.setUserPhoto(rs.getString(3));
        userList.add(userBean);
    }
    long endTime = System.currentTimeMillis();
    LogUtils.dbDebugLog(logger, startTime, userList.toString(), sql + "," + groupId + "," + startNum + "," + pageSize);
    return userList;
}
Also used : ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SimpleUserBean(com.akaxin.site.storage.bean.SimpleUserBean)

Example 13 with SimpleUserBean

use of com.akaxin.site.storage.bean.SimpleUserBean in project openzaly by akaxincom.

the class SQLiteUserProfileDao method querySimpleProfileById.

public SimpleUserBean querySimpleProfileById(String siteUserId) throws SQLException {
    long startTime = System.currentTimeMillis();
    String sql = "SELECT site_user_id,user_name,user_photo,user_status FROM " + USER_PROFILE_TABLE + " WHERE site_user_id=?;";
    PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
    preStatement.setString(1, siteUserId);
    ResultSet rs = preStatement.executeQuery();
    SimpleUserBean userBean = null;
    if (rs.next()) {
        userBean = new SimpleUserBean();
        userBean.setUserId(rs.getString(1));
        userBean.setUserName(rs.getString(2));
        userBean.setUserPhoto(rs.getString(3));
        userBean.setUserStatus(rs.getInt(4));
    }
    LogUtils.dbDebugLog(logger, startTime, userBean, sql, siteUserId);
    return userBean;
}
Also used : ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SimpleUserBean(com.akaxin.site.storage.bean.SimpleUserBean)

Example 14 with SimpleUserBean

use of com.akaxin.site.storage.bean.SimpleUserBean in project openzaly by akaxincom.

the class SQLiteUserProfileDao method querySimpleProfileByGlobalUserId.

public SimpleUserBean querySimpleProfileByGlobalUserId(String globalUserId) throws SQLException {
    long startTime = System.currentTimeMillis();
    SimpleUserBean userBean = new SimpleUserBean();
    String sql = "SELECT site_user_id,user_name,user_photo,user_status FROM " + USER_PROFILE_TABLE + " WHERE global_user_id=?;";
    PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
    preStatement.setString(1, globalUserId);
    ResultSet rs = preStatement.executeQuery();
    if (rs.next()) {
        userBean.setUserId(rs.getString(1));
        userBean.setUserName(rs.getString(2));
        userBean.setUserPhoto(rs.getString(3));
        userBean.setUserStatus(rs.getInt(4));
    }
    LogUtils.dbDebugLog(logger, startTime, userBean.toString(), sql, globalUserId);
    return userBean;
}
Also used : ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SimpleUserBean(com.akaxin.site.storage.bean.SimpleUserBean)

Aggregations

SimpleUserBean (com.akaxin.site.storage.bean.SimpleUserBean)14 PreparedStatement (java.sql.PreparedStatement)7 ResultSet (java.sql.ResultSet)7 CommandResponse (com.akaxin.common.command.CommandResponse)6 ErrorCode2 (com.akaxin.common.constant.ErrorCode2)6 ArrayList (java.util.ArrayList)5 UserProto (com.akaxin.proto.core.UserProto)4 GroupProto (com.akaxin.proto.core.GroupProto)1 HaiUserListProto (com.akaxin.proto.plugin.HaiUserListProto)1 HaiUserSearchProto (com.akaxin.proto.plugin.HaiUserSearchProto)1 ApiFriendListProto (com.akaxin.proto.site.ApiFriendListProto)1 ApiGroupNonMembersProto (com.akaxin.proto.site.ApiGroupNonMembersProto)1 ApiGroupProfileProto (com.akaxin.proto.site.ApiGroupProfileProto)1 ApiSiteLoginProto (com.akaxin.proto.site.ApiSiteLoginProto)1 GroupMemberBean (com.akaxin.site.storage.bean.GroupMemberBean)1 GroupProfileBean (com.akaxin.site.storage.bean.GroupProfileBean)1 UserDeviceBean (com.akaxin.site.storage.bean.UserDeviceBean)1 UserSessionBean (com.akaxin.site.storage.bean.UserSessionBean)1 ByteString (com.google.protobuf.ByteString)1 PublicKey (java.security.PublicKey)1