use of com.akaxin.common.command.CommandResponse 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.command.CommandResponse 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.command.CommandResponse 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.command.CommandResponse in project openzaly by akaxincom.
the class User2Notice method applyFriendNotice.
/**
* A用户添加用户B为好友,发送B有好友添加的申请 <br>
*
* 客户端接收到此通知,会在通讯录的好友申请提示
*
* @param siteUserId
* 用户B的用户ID
*/
public void applyFriendNotice(String siteUserId) {
List<String> deviceList = UserSessionDao.getInstance().getSessionDevices(siteUserId);
for (String deviceId : deviceList) {
CommandResponse commandResponse = new CommandResponse().setVersion(CommandConst.PROTOCOL_VERSION).setAction(CommandConst.IM_NOTICE);
ImStcNoticeProto.ImStcNoticeRequest noticeRequest = ImStcNoticeProto.ImStcNoticeRequest.newBuilder().setType(ImStcNoticeProto.NoticeType.APPLY_FRIEND).build();
commandResponse.setParams(noticeRequest.toByteArray());
commandResponse.setErrCode(ErrorCode.SUCCESS);
ChannelWriter.writeByDeviceId(deviceId, commandResponse);
logger.debug("apply friend notice. to siteUserId={} deviceId={}", siteUserId, deviceId);
}
}
use of com.akaxin.common.command.CommandResponse 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;
}
Aggregations