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;
}
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;
}
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;
}
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);
}
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);
}
Aggregations