Search in sources :

Example 66 with ErrorCode2

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

the class HttpUserService method list.

/**
 * 分页获取用户列表
 *
 * @param command
 * @return
 */
public CommandResponse list(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errorCode = ErrorCode2.ERROR;
    try {
        HaiUserListProto.HaiUserListRequest request = HaiUserListProto.HaiUserListRequest.parseFrom(command.getParams());
        int pageNum = request.getPageNumber();
        int pageSize = request.getPageSize();
        LogUtils.requestDebugLog(logger, command, request.toString());
        List<SimpleUserBean> pageList = UserProfileDao.getInstance().getUserPageList(pageNum, pageSize);
        if (pageList != null) {
            HaiUserListProto.HaiUserListResponse.Builder responseBuilder = HaiUserListProto.HaiUserListResponse.newBuilder();
            for (SimpleUserBean bean : pageList) {
                UserProto.SimpleUserProfile.Builder userProfileBuilder = UserProto.SimpleUserProfile.newBuilder();
                userProfileBuilder.setSiteUserId(bean.getUserId());
                if (StringUtils.isNotBlank(bean.getUserName())) {
                    userProfileBuilder.setUserName(bean.getUserName());
                }
                if (StringUtils.isNotBlank(bean.getUserPhoto())) {
                    userProfileBuilder.setUserPhoto(bean.getUserPhoto());
                }
                userProfileBuilder.setUserStatusValue(bean.getUserStatus());
                userProfileBuilder.setUserStatusValue(bean.getUserStatus());
                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);
}
Also used : ErrorCode2(com.akaxin.common.constant.ErrorCode2) HaiUserListProto(com.akaxin.proto.plugin.HaiUserListProto) CommandResponse(com.akaxin.common.command.CommandResponse) SimpleUserBean(com.akaxin.site.storage.bean.SimpleUserBean)

Example 67 with ErrorCode2

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

the class HttpUserService method search.

/**
 * 查找用户
 *
 * @param command
 * @return
 */
public CommandResponse search(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errorCode = ErrorCode2.ERROR;
    try {
        HaiUserSearchProto.HaiUserSearchRequest request = HaiUserSearchProto.HaiUserSearchRequest.parseFrom(command.getParams());
        String siteUserId = request.getSiteUserId();
        String userName = request.getUserName();
        LogUtils.requestDebugLog(logger, command, request.toString());
        List<SimpleUserBean> userList = new ArrayList<SimpleUserBean>();
        if (StringUtils.isNotBlank(siteUserId)) {
            userList.add(UserProfileDao.getInstance().getSimpleProfileById(siteUserId));
        } else if (StringUtils.isNotBlank(userName)) {
            userList = UserProfileDao.getInstance().getSimpleProfileByName(userName);
        } else {
            errorCode = ErrorCode2.ERROR_PARAMETER;
        }
        if (userList != null && userList.size() > 0) {
            HaiUserSearchProto.HaiUserSearchResponse.Builder responseBuilder = HaiUserSearchProto.HaiUserSearchResponse.newBuilder();
            for (SimpleUserBean bean : userList) {
                UserProto.SimpleUserProfile profile = UserProto.SimpleUserProfile.newBuilder().setSiteUserId(bean.getUserId()).setUserName(String.valueOf(bean.getUserName())).setUserPhoto(String.valueOf(bean.getUserPhoto())).build();
                responseBuilder.addUserProfile(profile);
            }
            commandResponse.setParams(responseBuilder.build().toByteArray());
            errorCode = ErrorCode2.SUCCESS;
        }
    } catch (Exception e) {
        errorCode = ErrorCode2.ERROR_SYSTEMERROR;
        LogUtils.requestErrorLog(logger, command, e);
    }
    return commandResponse.setErrCode2(errorCode);
}
Also used : UserProto(com.akaxin.proto.core.UserProto) ArrayList(java.util.ArrayList) CommandResponse(com.akaxin.common.command.CommandResponse) SimpleUserBean(com.akaxin.site.storage.bean.SimpleUserBean) ErrorCode2(com.akaxin.common.constant.ErrorCode2) HaiUserSearchProto(com.akaxin.proto.plugin.HaiUserSearchProto)

Example 68 with ErrorCode2

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

the class HttpUserService method profile.

/**
 * 查看用户的个人profile
 *
 * @param command
 * @return
 */
public CommandResponse profile(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errorCode = ErrorCode2.ERROR;
    try {
        HaiUserProfileProto.HaiUserProfileRequest request = HaiUserProfileProto.HaiUserProfileRequest.parseFrom(command.getParams());
        String siteUserId = request.getSiteUserId();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNotBlank(siteUserId)) {
            UserProfileBean bean = UserProfileDao.getInstance().getUserProfileById(siteUserId);
            if (bean != null && StringUtils.isNotBlank(bean.getSiteUserId())) {
                UserProto.UserProfile profile = UserProto.UserProfile.newBuilder().setSiteUserId(bean.getSiteUserId()).setUserName(String.valueOf(bean.getUserName())).setUserPhoto(String.valueOf(bean.getUserPhoto())).setUserStatusValue(bean.getUserStatus()).build();
                HaiUserProfileProto.HaiUserProfileResponse response = HaiUserProfileProto.HaiUserProfileResponse.newBuilder().setUserProfile(profile).build();
                commandResponse.setParams(response.toByteArray());
                errorCode = ErrorCode2.SUCCESS;
            }
        } else {
            errorCode = ErrorCode2.ERROR_PARAMETER;
        }
    } catch (Exception e) {
        errorCode = ErrorCode2.ERROR_SYSTEMERROR;
        LogUtils.requestErrorLog(logger, command, e);
    }
    return commandResponse.setErrCode2(errorCode);
}
Also used : ErrorCode2(com.akaxin.common.constant.ErrorCode2) UserProto(com.akaxin.proto.core.UserProto) CommandResponse(com.akaxin.common.command.CommandResponse) HaiUserProfileProto(com.akaxin.proto.plugin.HaiUserProfileProto) UserProfileBean(com.akaxin.site.storage.bean.UserProfileBean)

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