use of com.akaxin.site.storage.bean.ApplyUserBean in project openzaly by akaxincom.
the class SQLiteFriendApplyDao method queryApplyUsers.
/**
* 查询好友申请列表
*
* @param siteUserId
* @return
* @throws SQLException
*/
public List<ApplyUserBean> queryApplyUsers(String siteUserId) throws SQLException {
long startTime = System.currentTimeMillis();
List<ApplyUserBean> applyUsers = new ArrayList<ApplyUserBean>();
String sql = "SELECT a.site_friend_id,b.user_name,b.user_photo,a.apply_reason,MAX(a.apply_time) FROM " + FRIEND_APPLY_TABLE + " AS a LEFT JOIN " + SQLConst.SITE_USER_PROFILE + " AS b WHERE a.site_friend_id=b.site_user_id AND a.site_user_id=?;";
PreparedStatement preState = SQLiteJDBCManager.getConnection().prepareStatement(sql);
preState.setString(1, siteUserId);
ResultSet rs = preState.executeQuery();
while (rs.next()) {
ApplyUserBean userBean = new ApplyUserBean();
userBean.setUserId(rs.getString(1));
userBean.setUserName(rs.getString(2));
userBean.setUserPhoto(rs.getString(3));
userBean.setApplyReason(rs.getString(4));
userBean.setApplyTime(rs.getLong(5));
applyUsers.add(userBean);
}
LogUtils.dbDebugLog(logger, startTime, applyUsers.size(), sql, siteUserId);
return applyUsers;
}
use of com.akaxin.site.storage.bean.ApplyUserBean in project openzaly by akaxincom.
the class ApiFriendService method applyList.
/**
* 获取用户的好友申请列表
*
* @param command
* @return
*/
public CommandResponse applyList(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
String siteUserId = command.getSiteUserId();
LogUtils.requestDebugLog(logger, command, "");
if (StringUtils.isNotBlank(siteUserId)) {
List<ApplyUserBean> applyUserList = UserFriendDao.getInstance().getApplyUserList(siteUserId);
ApiFriendApplyListProto.ApiFriendApplyListResponse.Builder responseBuilder = ApiFriendApplyListProto.ApiFriendApplyListResponse.newBuilder();
for (ApplyUserBean applyUser : applyUserList) {
if (StringUtils.isNotEmpty(applyUser.getUserId())) {
UserProto.UserProfile.Builder userProfileBuilder = UserProto.UserProfile.newBuilder();
userProfileBuilder.setSiteUserId(applyUser.getUserId());
userProfileBuilder.setUserName(String.valueOf(applyUser.getUserName()));
userProfileBuilder.setUserPhoto(String.valueOf(applyUser.getUserPhoto()));
UserProto.ApplyUserProfile applyUserProfile = UserProto.ApplyUserProfile.newBuilder().setApplyUser(userProfileBuilder.build()).setApplyReason(String.valueOf(applyUser.getApplyReason())).build();
responseBuilder.addList(applyUserProfile);
}
}
commandResponse.setParams(responseBuilder.build().toByteArray());
errCode = ErrorCode2.SUCCESS;
}
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
Aggregations