Search in sources :

Example 46 with CommandResponse

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);
}
Also used : ApiFileUploadProto(com.akaxin.proto.site.ApiFileUploadProto) FileProto(com.akaxin.proto.core.FileProto) ErrorCode2(com.akaxin.common.constant.ErrorCode2) CommandResponse(com.akaxin.common.command.CommandResponse) ByteString(com.google.protobuf.ByteString)

Example 47 with CommandResponse

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);
}
Also used : ApiFriendDeleteProto(com.akaxin.proto.site.ApiFriendDeleteProto) ErrorCode2(com.akaxin.common.constant.ErrorCode2) CommandResponse(com.akaxin.common.command.CommandResponse)

Example 48 with CommandResponse

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);
}
Also used : ApiFriendUpdateSettingProto(com.akaxin.proto.site.ApiFriendUpdateSettingProto) ErrorCode2(com.akaxin.common.constant.ErrorCode2) CommandResponse(com.akaxin.common.command.CommandResponse) UserFriendBean(com.akaxin.site.storage.bean.UserFriendBean)

Example 49 with CommandResponse

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);
}
Also used : ErrorCode2(com.akaxin.common.constant.ErrorCode2) ApplyUserBean(com.akaxin.site.storage.bean.ApplyUserBean) UserProto(com.akaxin.proto.core.UserProto) CommandResponse(com.akaxin.common.command.CommandResponse)

Example 50 with CommandResponse

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);
}
Also used : ApiFriendSettingProto(com.akaxin.proto.site.ApiFriendSettingProto) ErrorCode2(com.akaxin.common.constant.ErrorCode2) CommandResponse(com.akaxin.common.command.CommandResponse) UserFriendBean(com.akaxin.site.storage.bean.UserFriendBean)

Aggregations

CommandResponse (com.akaxin.common.command.CommandResponse)82 ErrorCode2 (com.akaxin.common.constant.ErrorCode2)68 UserProto (com.akaxin.proto.core.UserProto)12 PluginBean (com.akaxin.site.storage.bean.PluginBean)7 ByteString (com.google.protobuf.ByteString)7 GroupProto (com.akaxin.proto.core.GroupProto)6 GroupProfileBean (com.akaxin.site.storage.bean.GroupProfileBean)6 SimpleUserBean (com.akaxin.site.storage.bean.SimpleUserBean)6 UserProfileBean (com.akaxin.site.storage.bean.UserProfileBean)6 UserDeviceBean (com.akaxin.site.storage.bean.UserDeviceBean)5 Command (com.akaxin.common.command.Command)4 DeviceProto (com.akaxin.proto.core.DeviceProto)4 ProtocolStringList (com.google.protobuf.ProtocolStringList)4 ConfigProto (com.akaxin.proto.core.ConfigProto)3 GroupMemberBean (com.akaxin.site.storage.bean.GroupMemberBean)3 UserGroupBean (com.akaxin.site.storage.bean.UserGroupBean)3 RedisCommand (com.akaxin.common.command.RedisCommand)2 ImStcPsnProto (com.akaxin.proto.client.ImStcPsnProto)2 CoreProto (com.akaxin.proto.core.CoreProto)2 FileProto (com.akaxin.proto.core.FileProto)2