Search in sources :

Example 51 with ErrorCode2

use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.

the class ApiUserService method mute.

public CommandResponse mute(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        String siteUserId = command.getSiteUserId();
        boolean mute = UserProfileDao.getInstance().getUserMute(siteUserId);
        LogUtils.requestDebugLog(logger, command, "");
        ApiUserMuteProto.ApiUserMuteResponse response = ApiUserMuteProto.ApiUserMuteResponse.newBuilder().setMute(mute).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 : ErrorCode2(com.akaxin.common.constant.ErrorCode2) CommandResponse(com.akaxin.common.command.CommandResponse) ApiUserMuteProto(com.akaxin.proto.site.ApiUserMuteProto)

Example 52 with ErrorCode2

use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.

the class ApiUserService method updateMute.

public CommandResponse updateMute(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiUserUpdateMuteProto.ApiUserUpdateMuteRequest request = ApiUserUpdateMuteProto.ApiUserUpdateMuteRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        boolean mute = request.getMute();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (UserProfileDao.getInstance().updateUserMute(siteUserId, mute)) {
            errCode = ErrorCode2.SUCCESS;
        } else {
            errCode = ErrorCode2.ERROR_DATABASE_EXECUTE;
        }
    } catch (Exception e) {
        errCode = ErrorCode2.ERROR_SYSTEMERROR;
        LogUtils.requestErrorLog(logger, command, e);
    }
    return commandResponse.setErrCode2(errCode);
}
Also used : ErrorCode2(com.akaxin.common.constant.ErrorCode2) ApiUserUpdateMuteProto(com.akaxin.proto.site.ApiUserUpdateMuteProto) CommandResponse(com.akaxin.common.command.CommandResponse)

Example 53 with ErrorCode2

use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.

the class ApiUserService method updateProfile.

/**
 * 更新用户个人信息
 *
 * @param command
 * @return
 */
public CommandResponse updateProfile(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiUserUpdateProfileProto.ApiUserUpdateProfileRequest request = ApiUserUpdateProfileProto.ApiUserUpdateProfileRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String userName = request.getUserProfile().getUserName();
        String userPhoto = request.getUserProfile().getUserPhoto();
        String introduce = request.getUserProfile().getSelfIntroduce();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNoneEmpty(siteUserId, userName, userPhoto)) {
            UserProfileBean userBean = new UserProfileBean();
            userBean.setSiteUserId(siteUserId);
            userBean.setUserName(userName);
            userBean.setUserPhoto(userPhoto);
            userBean.setSelfIntroduce(introduce);
            if (UserProfileDao.getInstance().updateUserProfile(userBean)) {
                errCode = ErrorCode2.SUCCESS;
            } else {
                errCode = ErrorCode2.ERROR2_USER_UPDATE_PROFILE;
            }
        } else {
            errCode = ErrorCode2.ERROR_PARAMETER;
        }
    } catch (Exception e) {
        errCode = ErrorCode2.ERROR_SYSTEMERROR;
        LogUtils.requestErrorLog(logger, command, e);
    }
    return commandResponse.setErrCode2(errCode);
}
Also used : ErrorCode2(com.akaxin.common.constant.ErrorCode2) ApiUserUpdateProfileProto(com.akaxin.proto.site.ApiUserUpdateProfileProto) CommandResponse(com.akaxin.common.command.CommandResponse) UserProfileBean(com.akaxin.site.storage.bean.UserProfileBean)

Example 54 with ErrorCode2

use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.

the class HttpGroupService method nonmembers.

public CommandResponse nonmembers(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        HaiGroupNonmembersProto.HaiGroupNonmembersRequest request = HaiGroupNonmembersProto.HaiGroupNonmembersRequest.parseFrom(command.getParams());
        String groupId = request.getGroupId();
        int pageNum = request.getPageNumber();
        int pageSize = request.getPageSize();
        LogUtils.requestDebugLog(logger, command, request.toString());
        List<GroupMemberBean> memberList = UserGroupDao.getInstance().getNonGroupMemberList(groupId, pageNum, pageSize);
        HaiGroupNonmembersProto.HaiGroupNonmembersResponse.Builder responseBuilder = HaiGroupNonmembersProto.HaiGroupNonmembersResponse.newBuilder();
        for (GroupMemberBean member : memberList) {
            GroupProto.GroupMemberRole memberRole = GroupProto.GroupMemberRole.NONMEMBER;
            UserProto.UserProfile memberProfile = UserProto.UserProfile.newBuilder().setSiteUserId(member.getUserId()).setUserName(String.valueOf(member.getUserName())).setUserPhoto(String.valueOf(member.getUserPhoto())).build();
            GroupProto.GroupMemberProfile groupMember = GroupProto.GroupMemberProfile.newBuilder().setRole(memberRole).setProfile(memberProfile).build();
            responseBuilder.addGroupMember(groupMember);
        }
        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 : GroupProto(com.akaxin.proto.core.GroupProto) UserProto(com.akaxin.proto.core.UserProto) CommandResponse(com.akaxin.common.command.CommandResponse) GroupMemberBean(com.akaxin.site.storage.bean.GroupMemberBean) ErrorCode2(com.akaxin.common.constant.ErrorCode2) HaiGroupNonmembersProto(com.akaxin.proto.plugin.HaiGroupNonmembersProto)

Example 55 with ErrorCode2

use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.

the class HttpGroupService method members.

/**
 * 获取群成员列表
 *
 * @param command
 * @return
 */
public CommandResponse members(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        HaiGroupMembersProto.HaiGroupMembersRequest request = HaiGroupMembersProto.HaiGroupMembersRequest.parseFrom(command.getParams());
        String groupId = request.getGroupId();
        int pageNum = request.getPageNumber();
        int pageSize = request.getPageSize();
        if (pageNum == 0 && pageSize == 0) {
            pageNum = 1;
            pageSize = GroupConfig.GROUP_MAX_MEMBER_COUNT;
        }
        LogUtils.requestDebugLog(logger, command, request.toString());
        List<GroupMemberBean> memberList = UserGroupDao.getInstance().getGroupMemberList(groupId, pageNum, pageSize);
        HaiGroupMembersProto.HaiGroupMembersResponse.Builder responseBuilder = HaiGroupMembersProto.HaiGroupMembersResponse.newBuilder();
        for (GroupMemberBean member : memberList) {
            GroupProto.GroupMemberRole memberRole = GroupProto.GroupMemberRole.forNumber(member.getUserRole());
            UserProto.UserProfile memberProfile = UserProto.UserProfile.newBuilder().setSiteUserId(member.getUserId()).setUserName(String.valueOf(member.getUserName())).setUserPhoto(String.valueOf(member.getUserPhoto())).build();
            GroupProto.GroupMemberProfile groupMember = GroupProto.GroupMemberProfile.newBuilder().setRole(memberRole).setProfile(memberProfile).build();
            responseBuilder.addGroupMember(groupMember);
        }
        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 : GroupProto(com.akaxin.proto.core.GroupProto) UserProto(com.akaxin.proto.core.UserProto) CommandResponse(com.akaxin.common.command.CommandResponse) GroupMemberBean(com.akaxin.site.storage.bean.GroupMemberBean) ErrorCode2(com.akaxin.common.constant.ErrorCode2) HaiGroupMembersProto(com.akaxin.proto.plugin.HaiGroupMembersProto)

Aggregations

CommandResponse (com.akaxin.common.command.CommandResponse)68 ErrorCode2 (com.akaxin.common.constant.ErrorCode2)68 UserProto (com.akaxin.proto.core.UserProto)12 PluginBean (com.akaxin.site.storage.bean.PluginBean)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 ByteString (com.google.protobuf.ByteString)5 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 FileProto (com.akaxin.proto.core.FileProto)2 HaiSiteUpdateConfigProto (com.akaxin.proto.plugin.HaiSiteUpdateConfigProto)2 ApiFriendSettingProto (com.akaxin.proto.site.ApiFriendSettingProto)2 ApiGroupUpdateSettingProto (com.akaxin.proto.site.ApiGroupUpdateSettingProto)2 User2Notice (com.akaxin.site.business.impl.notice.User2Notice)2