use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.
the class HttpUserService method relationList.
/**
* 分页获取用户列表,同时附带与当前用户之间关系
*
* @param command
* @return
*/
public CommandResponse relationList(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errorCode = ErrorCode2.ERROR;
try {
HaiUserRelationListProto.HaiUserRelationListRequest request = HaiUserRelationListProto.HaiUserRelationListRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
int pageNum = request.getPageNumber();
int pageSize = request.getPageSize();
LogUtils.requestDebugLog(logger, command, request.toString());
List<SimpleUserRelationBean> pageList = UserProfileDao.getInstance().getUserRelationPageList(siteUserId, pageNum, pageSize);
if (pageList != null) {
HaiUserRelationListProto.HaiUserRelationListResponse.Builder responseBuilder = HaiUserRelationListProto.HaiUserRelationListResponse.newBuilder();
for (SimpleUserRelationBean bean : pageList) {
UserProto.UserRelationProfile.Builder userProfileBuilder = UserProto.UserRelationProfile.newBuilder();
UserProto.SimpleUserProfile.Builder supBuilder = UserProto.SimpleUserProfile.newBuilder();
supBuilder.setSiteUserId(bean.getUserId());
if (StringUtils.isNotBlank(bean.getUserId())) {
supBuilder.setUserName(String.valueOf(bean.getUserName()));
}
if (StringUtils.isNotBlank(bean.getUserPhoto())) {
supBuilder.setUserPhoto(bean.getUserPhoto());
}
supBuilder.setUserStatusValue(bean.getUserStatus());
userProfileBuilder.setProfile(supBuilder);
userProfileBuilder.setRelationValue(bean.getRelation());
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.common.constant.ErrorCode2 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.common.constant.ErrorCode2 in project openzaly by akaxincom.
the class HttpUserService method sealUp.
/**
* <pre>
* 禁封/解禁 用户身份
* </pre>
*
* @param command
* @return
*/
public CommandResponse sealUp(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
HaiUserSealUpProto.HaiUserSealUpRequest request = HaiUserSealUpProto.HaiUserSealUpRequest.parseFrom(command.getParams());
String siteUserId = request.getSiteUserId();
UserProto.UserStatus userStatus = request.getStatus();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(siteUserId)) {
if (UserProfileDao.getInstance().updateUserStatus(siteUserId, userStatus.getNumber())) {
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.common.constant.ErrorCode2 in project openzaly by akaxincom.
the class AbstractRequest method executeMethodByReflect.
private CommandResponse executeMethodByReflect(Command command) {
CommandResponse response = null;
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
String methodName = command.getMethod();
Method m = this.getClass().getDeclaredMethod(methodName, command.getClass());
response = (CommandResponse) m.invoke(this, command);
} catch (Exception e) {
LogUtils.requestErrorLog(logger, command, e);
}
if (response == null) {
response = new CommandResponse().setVersion(CommandConst.PROTOCOL_VERSION).setAction(CommandConst.ACTION_RES).setErrCode2(errCode);
}
return response;
}
use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.
the class HttpFriendService method apply.
/**
* 提供扩展服务中添加好友的功能
*
* @param command
* @return
*/
public CommandResponse apply(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
HaiFriendApplyProto.HaiFriendApplyRequest request = HaiFriendApplyProto.HaiFriendApplyRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String siteFriendId = request.getSiteFriendId();
String applyReason = request.getApplyReason();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isBlank(siteUserId)) {
errCode = ErrorCode2.ERROR_PARAMETER;
} else if (siteUserId.equals(siteFriendId)) {
errCode = ErrorCode2.ERROR2_FRIEND_APPLYSELF;
} else {
int applyTimes = UserFriendDao.getInstance().getApplyCount(siteFriendId, siteUserId);
if (applyTimes >= 5) {
errCode = ErrorCode2.ERROR2_FRIEND_APPLYCOUNT;
} else {
if (UserFriendDao.getInstance().saveFriendApply(siteUserId, siteFriendId, applyReason)) {
errCode = ErrorCode2.SUCCESS;
}
}
}
if (ErrorCode2.SUCCESS.equals(errCode)) {
logger.debug("user apply friend notice. to siteUserId={}", siteFriendId);
new User2Notice().applyFriendNotice(siteFriendId);
}
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
Aggregations