Search in sources :

Example 6 with GroupMemberBean

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

the class SQLiteUserGroupDao method queryGroupMemberList.

public List<GroupMemberBean> queryGroupMemberList(String groupId, int pageNum, int pageSize) throws SQLException {
    long startTime = System.currentTimeMillis();
    List<GroupMemberBean> membersList = new ArrayList<GroupMemberBean>();
    int startNum = (pageNum - 1) * pageSize;
    String sql = "SELECT DISTINCT a.site_user_id,b.user_name,b.user_photo,a.user_role FROM " + USER_GROUP_TABLE + " AS a LEFT JOIN " + SQLConst.SITE_USER_PROFILE + " AS b WHERE a.site_user_id=b.site_user_id AND a.site_group_id=? limit ?,?;";
    PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
    preStatement.setString(1, groupId);
    preStatement.setInt(2, startNum);
    preStatement.setInt(3, pageSize);
    ResultSet rs = preStatement.executeQuery();
    while (rs.next()) {
        GroupMemberBean member = new GroupMemberBean();
        member.setUserId(rs.getString(1));
        member.setUserName(rs.getString(2));
        member.setUserPhoto(rs.getString(3));
        member.setUserRole(rs.getInt(4));
        membersList.add(member);
    }
    long endTime = System.currentTimeMillis();
    LogUtils.dbDebugLog(logger, startTime, membersList.toString(), sql + "," + groupId);
    return membersList;
}
Also used : ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) GroupMemberBean(com.akaxin.site.storage.bean.GroupMemberBean)

Example 7 with GroupMemberBean

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

the class SQLiteUserGroupDao method queryNonGroupMemberList.

public List<GroupMemberBean> queryNonGroupMemberList(String groupId, int pageNum, int pageSize) throws SQLException {
    long startTime = System.currentTimeMillis();
    List<GroupMemberBean> membersList = new ArrayList<GroupMemberBean>();
    int startNum = (pageNum - 1) * pageSize;
    String sql = "SELECT site_user_id,user_name,user_photo FROM " + SQLConst.SITE_USER_PROFILE + " WHERE site_user_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, groupId);
    preStatement.setInt(2, startNum);
    preStatement.setInt(3, pageSize);
    ResultSet rs = preStatement.executeQuery();
    while (rs.next()) {
        GroupMemberBean member = new GroupMemberBean();
        member.setUserId(rs.getString(1));
        member.setUserName(rs.getString(2));
        member.setUserPhoto(rs.getString(3));
        member.setUserRole(GroupProto.GroupMemberRole.NONMEMBER_VALUE);
        membersList.add(member);
    }
    long endTime = System.currentTimeMillis();
    LogUtils.dbDebugLog(logger, startTime, membersList.toString(), sql + "," + groupId);
    return membersList;
}
Also used : ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) GroupMemberBean(com.akaxin.site.storage.bean.GroupMemberBean)

Aggregations

GroupMemberBean (com.akaxin.site.storage.bean.GroupMemberBean)7 CommandResponse (com.akaxin.common.command.CommandResponse)4 ErrorCode2 (com.akaxin.common.constant.ErrorCode2)4 GroupProto (com.akaxin.proto.core.GroupProto)4 UserProto (com.akaxin.proto.core.UserProto)4 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 ArrayList (java.util.ArrayList)2 HaiGroupMembersProto (com.akaxin.proto.plugin.HaiGroupMembersProto)1 HaiGroupNonmembersProto (com.akaxin.proto.plugin.HaiGroupNonmembersProto)1 ApiGroupMembersProto (com.akaxin.proto.site.ApiGroupMembersProto)1 ApiGroupProfileProto (com.akaxin.proto.site.ApiGroupProfileProto)1 GroupProfileBean (com.akaxin.site.storage.bean.GroupProfileBean)1 SimpleUserBean (com.akaxin.site.storage.bean.SimpleUserBean)1