Search in sources :

Example 61 with CommandResponse

use of com.akaxin.common.command.CommandResponse 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 62 with CommandResponse

use of com.akaxin.common.command.CommandResponse 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 63 with CommandResponse

use of com.akaxin.common.command.CommandResponse 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)

Example 64 with CommandResponse

use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.

the class HttpGroupService method delete.

/**
 * 删除群组
 *
 * @param command
 * @return
 */
public CommandResponse delete(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        HaiGroupDeleteProto.HaiGroupDeleteRequest request = HaiGroupDeleteProto.HaiGroupDeleteRequest.parseFrom(command.getParams());
        String groupId = request.getGroupId();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNotBlank(groupId)) {
            if (UserGroupDao.getInstance().deleteGroup(groupId)) {
                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 : ErrorCode2(com.akaxin.common.constant.ErrorCode2) HaiGroupDeleteProto(com.akaxin.proto.plugin.HaiGroupDeleteProto) CommandResponse(com.akaxin.common.command.CommandResponse)

Example 65 with CommandResponse

use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.

the class HttpGroupService method removeMember.

/**
 * 删除群成员
 *
 * @param command
 * @return
 */
public CommandResponse removeMember(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        HaiGroupRemoveMemberProto.HaiGroupRemoveMemberRequest request = HaiGroupRemoveMemberProto.HaiGroupRemoveMemberRequest.parseFrom(command.getParams());
        String groupId = request.getGroupId();
        ProtocolStringList deleteMemberIds = request.getGroupMemberList();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNotBlank(groupId)) {
            if (UserGroupDao.getInstance().deleteGroupMember(groupId, deleteMemberIds)) {
                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 : ErrorCode2(com.akaxin.common.constant.ErrorCode2) HaiGroupRemoveMemberProto(com.akaxin.proto.plugin.HaiGroupRemoveMemberProto) CommandResponse(com.akaxin.common.command.CommandResponse) ProtocolStringList(com.google.protobuf.ProtocolStringList)

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