use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.
the class ApiFileService method upload.
public CommandResponse upload(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiFileUploadProto.ApiFileUploadRequest request = ApiFileUploadProto.ApiFileUploadRequest.parseFrom(command.getParams());
FileProto.File file = request.getFile();
int type = file.getFileTypeValue();
byte[] content = file.getFileContent().toByteArray();
LogUtils.requestDebugLog(logger, command, "type=" + type + ",size=" + content.length);
String fileId = FileServerUtils.saveFile(content, FilePathUtils.getPicPath(), type);
ApiFileUploadProto.ApiFileUploadResponse response = ApiFileUploadProto.ApiFileUploadResponse.newBuilder().setFileId(fileId).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.common.command.CommandResponse in project openzaly by akaxincom.
the class ApiFriendService method delete.
/**
* 用户删除好友列表中的其他用户
*
* @param command
* @return
*/
public CommandResponse delete(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiFriendDeleteProto.ApiFriendDeleteRequest request = ApiFriendDeleteProto.ApiFriendDeleteRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String siteFriendId = request.getSiteFriendId();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(siteUserId) && StringUtils.isNotBlank(siteFriendId) && !siteUserId.equals(siteFriendId)) {
if (UserFriendDao.getInstance().deleteFriend(siteUserId, siteFriendId)) {
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 ApiFriendService method updateSetting.
/**
* 对用户设置消息免打扰功能
*
* @param command
* @return
*/
public CommandResponse updateSetting(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiFriendUpdateSettingProto.ApiFriendUpdateSettingRequest request = ApiFriendUpdateSettingProto.ApiFriendUpdateSettingRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String siteFriendId = request.getSiteFriendId();
boolean messageMute = request.getMessageMute();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNoneBlank(siteUserId, siteFriendId)) {
UserFriendBean friendBean = new UserFriendBean();
friendBean.setSiteUserId(siteFriendId);
friendBean.setMute(messageMute);
if (UserFriendDao.getInstance().updateFriendSetting(siteUserId, friendBean)) {
errCode = ErrorCode2.SUCCESS;
} else {
errCode = ErrorCode2.ERROR_DATABASE_EXECUTE;
}
} 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 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);
}
use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.
the class ApiFriendService method setting.
/**
* 获取好友的设置信息
*
* @param command
* @return
*/
public CommandResponse setting(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiFriendSettingProto.ApiFriendSettingRequest request = ApiFriendSettingProto.ApiFriendSettingRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String siteFriendId = request.getSiteFriendId();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNoneEmpty(siteUserId, siteFriendId)) {
UserFriendBean bean = UserFriendDao.getInstance().getFriendSetting(siteUserId, siteFriendId);
if (bean != null) {
ApiFriendSettingProto.ApiFriendSettingResponse response = ApiFriendSettingProto.ApiFriendSettingResponse.newBuilder().setMessageMute(bean.isMute()).build();
commandResponse.setParams(response.toByteArray());
errCode = ErrorCode2.SUCCESS;
} else {
// 数据库执行错误
errCode = ErrorCode2.ERROR_DATABASE_EXECUTE;
}
} else {
errCode = ErrorCode2.ERROR_PARAMETER;
}
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
Aggregations