Search in sources :

Example 6 with SimpleUserBean

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

the class SQLiteUserProfileDao method querySimpleProfileByPubk.

public SimpleUserBean querySimpleProfileByPubk(String userIdPubk) throws SQLException {
    long startTime = System.currentTimeMillis();
    String sql = "SELECT site_user_id,user_name,user_photo,user_status FROM " + USER_PROFILE_TABLE + " WHERE user_id_pubk=?;";
    PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
    preStatement.setString(1, userIdPubk);
    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, userIdPubk);
    return userBean;
}
Also used : ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SimpleUserBean(com.akaxin.site.storage.bean.SimpleUserBean)

Example 7 with SimpleUserBean

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

the class SQLiteUserProfileDao method querySimpleProfileByName.

public List<SimpleUserBean> querySimpleProfileByName(String userName) throws SQLException {
    long startTime = System.currentTimeMillis();
    List<SimpleUserBean> userList = new ArrayList<SimpleUserBean>();
    String sql = "SELECT site_user_id,user_name,user_photo,user_status FROM " + USER_PROFILE_TABLE + " WHERE user_name LIKE ?;";
    PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
    preStatement.setString(1, "%" + userName + "%");
    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));
        userBean.setUserStatus(rs.getInt(4));
        userList.add(userBean);
    }
    LogUtils.dbDebugLog(logger, startTime, userList, sql, userName);
    return userList;
}
Also used : ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SimpleUserBean(com.akaxin.site.storage.bean.SimpleUserBean)

Example 8 with SimpleUserBean

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

the class SQLiteUserProfileDao method queryUserFriends.

public List<SimpleUserBean> queryUserFriends(String siteUserId) throws SQLException {
    long startTime = System.currentTimeMillis();
    List<SimpleUserBean> userFriendList = new ArrayList<SimpleUserBean>();
    String sql = "SELECT a.site_friend_id,b.user_name,b.user_photo FROM " + USER_FRIEND_TABLE + " AS a LEFT JOIN " + USER_PROFILE_TABLE + " AS b WHERE a.site_friend_id=b.site_user_id AND a.site_user_id=?;";
    PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
    preStatement.setString(1, siteUserId);
    ResultSet rs = preStatement.executeQuery();
    while (rs.next()) {
        SimpleUserBean bean = new SimpleUserBean();
        bean.setUserId(rs.getString(1));
        bean.setUserName(rs.getString(2));
        bean.setUserPhoto(rs.getString(3));
        userFriendList.add(bean);
    }
    LogUtils.dbDebugLog(logger, startTime, userFriendList.size(), sql, siteUserId);
    return userFriendList;
}
Also used : ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SimpleUserBean(com.akaxin.site.storage.bean.SimpleUserBean)

Example 9 with SimpleUserBean

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

the class HttpUserService method list.

/**
 * 分页获取用户列表
 *
 * @param command
 * @return
 */
public CommandResponse list(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errorCode = ErrorCode2.ERROR;
    try {
        HaiUserListProto.HaiUserListRequest request = HaiUserListProto.HaiUserListRequest.parseFrom(command.getParams());
        int pageNum = request.getPageNumber();
        int pageSize = request.getPageSize();
        LogUtils.requestDebugLog(logger, command, request.toString());
        List<SimpleUserBean> pageList = UserProfileDao.getInstance().getUserPageList(pageNum, pageSize);
        if (pageList != null) {
            HaiUserListProto.HaiUserListResponse.Builder responseBuilder = HaiUserListProto.HaiUserListResponse.newBuilder();
            for (SimpleUserBean bean : pageList) {
                UserProto.SimpleUserProfile.Builder userProfileBuilder = UserProto.SimpleUserProfile.newBuilder();
                userProfileBuilder.setSiteUserId(bean.getUserId());
                if (StringUtils.isNotBlank(bean.getUserName())) {
                    userProfileBuilder.setUserName(bean.getUserName());
                }
                if (StringUtils.isNotBlank(bean.getUserPhoto())) {
                    userProfileBuilder.setUserPhoto(bean.getUserPhoto());
                }
                userProfileBuilder.setUserStatusValue(bean.getUserStatus());
                userProfileBuilder.setUserStatusValue(bean.getUserStatus());
                responseBuilder.addUserProfile(userProfileBuilder.build());
            }
            commandResponse.setParams(responseBuilder.build().toByteArray());
            errorCode = ErrorCode2.SUCCESS;
        }
    } catch (Exception e) {
        errorCode = ErrorCode2.ERROR_SYSTEMERROR;
        LogUtils.requestErrorLog(logger, command, e);
    }
    return commandResponse.setErrCode2(errorCode);
}
Also used : ErrorCode2(com.akaxin.common.constant.ErrorCode2) HaiUserListProto(com.akaxin.proto.plugin.HaiUserListProto) CommandResponse(com.akaxin.common.command.CommandResponse) SimpleUserBean(com.akaxin.site.storage.bean.SimpleUserBean)

Example 10 with SimpleUserBean

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

the class HttpUserService method search.

/**
 * 查找用户
 *
 * @param command
 * @return
 */
public CommandResponse search(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errorCode = ErrorCode2.ERROR;
    try {
        HaiUserSearchProto.HaiUserSearchRequest request = HaiUserSearchProto.HaiUserSearchRequest.parseFrom(command.getParams());
        String siteUserId = request.getSiteUserId();
        String userName = request.getUserName();
        LogUtils.requestDebugLog(logger, command, request.toString());
        List<SimpleUserBean> userList = new ArrayList<SimpleUserBean>();
        if (StringUtils.isNotBlank(siteUserId)) {
            userList.add(UserProfileDao.getInstance().getSimpleProfileById(siteUserId));
        } else if (StringUtils.isNotBlank(userName)) {
            userList = UserProfileDao.getInstance().getSimpleProfileByName(userName);
        } else {
            errorCode = ErrorCode2.ERROR_PARAMETER;
        }
        if (userList != null && userList.size() > 0) {
            HaiUserSearchProto.HaiUserSearchResponse.Builder responseBuilder = HaiUserSearchProto.HaiUserSearchResponse.newBuilder();
            for (SimpleUserBean bean : userList) {
                UserProto.SimpleUserProfile profile = UserProto.SimpleUserProfile.newBuilder().setSiteUserId(bean.getUserId()).setUserName(String.valueOf(bean.getUserName())).setUserPhoto(String.valueOf(bean.getUserPhoto())).build();
                responseBuilder.addUserProfile(profile);
            }
            commandResponse.setParams(responseBuilder.build().toByteArray());
            errorCode = ErrorCode2.SUCCESS;
        }
    } catch (Exception e) {
        errorCode = ErrorCode2.ERROR_SYSTEMERROR;
        LogUtils.requestErrorLog(logger, command, e);
    }
    return commandResponse.setErrCode2(errorCode);
}
Also used : UserProto(com.akaxin.proto.core.UserProto) ArrayList(java.util.ArrayList) CommandResponse(com.akaxin.common.command.CommandResponse) SimpleUserBean(com.akaxin.site.storage.bean.SimpleUserBean) ErrorCode2(com.akaxin.common.constant.ErrorCode2) HaiUserSearchProto(com.akaxin.proto.plugin.HaiUserSearchProto)

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