use of com.akaxin.site.storage.bean.UserProfileBean in project openzaly by akaxincom.
the class ApiFriendService method profile.
/**
* 查询好友的个人资料
*
* @param command
* @return
*/
public CommandResponse profile(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiFriendProfileProto.ApiFriendProfileRequest request = ApiFriendProfileProto.ApiFriendProfileRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
// 等待查询的站点用户ID || globalUserId
String globalOrSiteFriendId = request.getSiteUserId();
// 等待查询的用户公钥,优先级高
String userIdPubk = request.getUserIdPubk();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isAllEmpty(userIdPubk, globalOrSiteFriendId)) {
errCode = ErrorCode2.ERROR_PARAMETER;
return commandResponse.setErrCode2(errCode);
}
UserProfileBean userBean = UserProfileDao.getInstance().getUserProfileById(globalOrSiteFriendId);
if (null == userBean || StringUtils.isBlank(userBean.getSiteUserId())) {
// 直接复用之前的接口了。
userBean = UserProfileDao.getInstance().getUserProfileByGlobalUserId(globalOrSiteFriendId);
}
if (userBean != null && StringUtils.isNotBlank(userBean.getSiteUserId())) {
UserProto.UserProfile userProfileProto = UserProto.UserProfile.newBuilder().setSiteUserId(String.valueOf(userBean.getSiteUserId())).setUserName(String.valueOf(userBean.getUserName())).setUserPhoto(String.valueOf(userBean.getUserPhoto())).setUserStatusValue(userBean.getUserStatus()).build();
UserProto.UserRelation userRelation = UserFriendDao.getInstance().getUserRelation(siteUserId, userBean.getSiteUserId());
ApiFriendProfileProto.ApiFriendProfileResponse response = ApiFriendProfileProto.ApiFriendProfileResponse.newBuilder().setProfile(userProfileProto).setRelation(userRelation).setUserIdPubk(userBean.getUserIdPubk()).build();
commandResponse.setParams(response.toByteArray());
errCode = ErrorCode2.SUCCESS;
}
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
use of com.akaxin.site.storage.bean.UserProfileBean in project openzaly by akaxincom.
the class ApiUserService method profile.
/**
* 获取用户个人资料信息
*
* 支持使用globalUserid与siteUserId
*
* @param command
* @return
*/
public CommandResponse profile(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errorCode = ErrorCode2.ERROR;
try {
ApiUserProfileProto.ApiUserProfileRequest request = ApiUserProfileProto.ApiUserProfileRequest.parseFrom(command.getParams());
String currentUserId = command.getSiteUserId();
String siteUserId = request.getSiteUserId();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(siteUserId) && siteUserId.equals(currentUserId)) {
UserProfileBean userBean = UserProfileDao.getInstance().getUserProfileById(siteUserId);
if (null == userBean) {
// 直接复用之前的接口了。
userBean = UserProfileDao.getInstance().getUserProfileByGlobalUserId(siteUserId);
}
if (userBean != null && StringUtils.isNotBlank(userBean.getSiteUserId())) {
UserProto.UserProfile.Builder userProfileBuilder = UserProto.UserProfile.newBuilder();
userProfileBuilder.setSiteUserId(userBean.getSiteUserId());
if (userBean.getUserName() != null) {
userProfileBuilder.setUserName(userBean.getUserName());
}
if (userBean.getUserPhoto() != null) {
userProfileBuilder.setUserPhoto(userBean.getUserPhoto());
}
if (userBean.getSelfIntroduce() != null) {
userProfileBuilder.setSelfIntroduce(userBean.getSelfIntroduce());
}
userProfileBuilder.setUserStatusValue(userBean.getUserStatus());
ApiUserProfileProto.ApiUserProfileResponse response = ApiUserProfileProto.ApiUserProfileResponse.newBuilder().setUserProfile(userProfileBuilder.build()).build();
commandResponse.setParams(response.toByteArray());
errorCode = ErrorCode2.SUCCESS;
}
} else {
errorCode = ErrorCode2.ERROR_PARAMETER;
}
} catch (Exception e) {
errorCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errorCode);
}
use of com.akaxin.site.storage.bean.UserProfileBean in project openzaly by akaxincom.
the class HttpUserService method update.
/**
* 更新用户信息
*
* @param command
* @return
*/
public CommandResponse update(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
HaiUserUpdateProto.HaiUserUpdateRequest request = HaiUserUpdateProto.HaiUserUpdateRequest.parseFrom(command.getParams());
String siteUserId = request.getUserProfile().getSiteUserId();
String userName = request.getUserProfile().getUserName();
String userPhoto = request.getUserProfile().getUserPhoto();
String userIntro = request.getUserProfile().getSelfIntroduce();
LogUtils.requestDebugLog(logger, command, request.toString());
// 过滤参数
if (StringUtils.isNoneBlank(siteUserId)) {
UserProfileBean bean = new UserProfileBean();
bean.setSiteUserId(siteUserId);
bean.setUserName(userName);
bean.setUserPhoto(userPhoto);
bean.setSelfIntroduce(userIntro);
if (UserProfileDao.getInstance().updateUserProfile(bean)) {
errCode = ErrorCode2.SUCCESS;
}
} else {
errCode = ErrorCode2.ERROR_PARAMETER;
}
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
use of com.akaxin.site.storage.bean.UserProfileBean in project openzaly by akaxincom.
the class UserProfileDao method getUserProfileByGlobalUserId.
public UserProfileBean getUserProfileByGlobalUserId(String id) {
UserProfileBean userBean = null;
try {
userBean = userProfileDao.getUserProfileByGlobalUserId(id);
userBean.setGlobalUserId(id);
} catch (SQLException e) {
logger.error("get user profile by userId error.", e);
}
return userBean;
}
use of com.akaxin.site.storage.bean.UserProfileBean in project openzaly by akaxincom.
the class SQLiteUserProfileDao method queryUserProfileByPubk.
public UserProfileBean queryUserProfileByPubk(String userIdPubk) throws SQLException {
long startTime = System.currentTimeMillis();
String sql = "SELECT site_user_id,user_id_pubk,user_name,user_photo,user_status,self_introduce,register_time FROM " + USER_PROFILE_TABLE + " WHERE user_id_pubk=?;";
PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
preStatement.setString(1, userIdPubk);
ResultSet rs = preStatement.executeQuery();
UserProfileBean userBean = null;
if (rs.next()) {
userBean = new UserProfileBean();
userBean.setSiteUserId(rs.getString(1));
userBean.setUserIdPubk(rs.getString(2));
userBean.setUserName(rs.getString(3));
userBean.setUserPhoto(rs.getString(4));
userBean.setUserStatus(rs.getInt(5));
userBean.setSelfIntroduce(rs.getString(6));
userBean.setRegisterTime(rs.getLong(7));
}
LogUtils.dbDebugLog(logger, startTime, userBean, sql, userIdPubk);
return userBean;
}
Aggregations