Search in sources :

Example 1 with UserGroupBean

use of com.akaxin.site.storage.bean.UserGroupBean in project openzaly by akaxincom.

the class ApiGroupService method setting.

/**
 * 获取个人对群的设置
 *
 * @param command
 * @return
 */
public CommandResponse setting(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiGroupSettingProto.ApiGroupSettingRequest request = ApiGroupSettingProto.ApiGroupSettingRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String groupId = request.getGroupId();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNoneEmpty(siteUserId, groupId)) {
            UserGroupBean bean = UserGroupDao.getInstance().getUserGroupSetting(siteUserId, groupId);
            if (bean != null) {
                ApiGroupSettingProto.ApiGroupSettingResponse response = ApiGroupSettingProto.ApiGroupSettingResponse.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 : ErrorCode2(com.akaxin.common.constant.ErrorCode2) UserGroupBean(com.akaxin.site.storage.bean.UserGroupBean) CommandResponse(com.akaxin.common.command.CommandResponse) ApiGroupSettingProto(com.akaxin.proto.site.ApiGroupSettingProto)

Example 2 with UserGroupBean

use of com.akaxin.site.storage.bean.UserGroupBean in project openzaly by akaxincom.

the class ApiGroupService method updateMute.

/**
 * 个人更新群设置信息
 *
 * @param command
 * @return
 */
public CommandResponse updateMute(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiGroupUpdateSettingProto.ApiGroupUpdateSettingRequest request = ApiGroupUpdateSettingProto.ApiGroupUpdateSettingRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String groupId = request.getGroupId();
        boolean isMute = request.getMessageMute();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNoneEmpty(siteUserId, groupId)) {
            UserGroupBean bean = new UserGroupBean();
            bean.setSiteGroupId(groupId);
            bean.setMute(isMute);
            if (UserGroupDao.getInstance().updateUserGroupSetting(siteUserId, bean)) {
                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 : ErrorCode2(com.akaxin.common.constant.ErrorCode2) UserGroupBean(com.akaxin.site.storage.bean.UserGroupBean) CommandResponse(com.akaxin.common.command.CommandResponse) ApiGroupUpdateSettingProto(com.akaxin.proto.site.ApiGroupUpdateSettingProto)

Example 3 with UserGroupBean

use of com.akaxin.site.storage.bean.UserGroupBean in project openzaly by akaxincom.

the class ApiGroupService method updateSetting.

/**
 * 个人更新群设置信息
 *
 * @param command
 * @return
 */
public CommandResponse updateSetting(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiGroupUpdateSettingProto.ApiGroupUpdateSettingRequest request = ApiGroupUpdateSettingProto.ApiGroupUpdateSettingRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String groupId = request.getGroupId();
        boolean isMute = request.getMessageMute();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNoneEmpty(siteUserId, groupId)) {
            UserGroupBean bean = new UserGroupBean();
            bean.setSiteGroupId(groupId);
            bean.setMute(isMute);
            if (UserGroupDao.getInstance().updateUserGroupSetting(siteUserId, bean)) {
                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 : ErrorCode2(com.akaxin.common.constant.ErrorCode2) UserGroupBean(com.akaxin.site.storage.bean.UserGroupBean) CommandResponse(com.akaxin.common.command.CommandResponse) ApiGroupUpdateSettingProto(com.akaxin.proto.site.ApiGroupUpdateSettingProto)

Example 4 with UserGroupBean

use of com.akaxin.site.storage.bean.UserGroupBean in project openzaly by akaxincom.

the class UserGroupDao method getUserGroupSetting.

public UserGroupBean getUserGroupSetting(String siteUserId, String siteGroupId) {
    try {
        UserGroupBean bean = userGroupDao.getUserGroupSetting(siteUserId, siteGroupId);
        if (bean == null) {
            bean = new UserGroupBean();
            bean.setMute(false);
        }
        return bean;
    } catch (SQLException e) {
        logger.error("get user group setting error", e);
    }
    return null;
}
Also used : SQLException(java.sql.SQLException) UserGroupBean(com.akaxin.site.storage.bean.UserGroupBean)

Example 5 with UserGroupBean

use of com.akaxin.site.storage.bean.UserGroupBean in project openzaly by akaxincom.

the class ApiGroupService method mute.

public CommandResponse mute(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiGroupMuteProto.ApiGroupMuteRequest request = ApiGroupMuteProto.ApiGroupMuteRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String siteGroupId = request.getSiteGroupId();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNoneEmpty(siteGroupId, siteUserId)) {
            UserGroupBean bean = UserGroupDao.getInstance().getUserGroupSetting(siteUserId, siteGroupId);
            if (bean != null) {
                ApiGroupSettingProto.ApiGroupSettingResponse response = ApiGroupSettingProto.ApiGroupSettingResponse.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 : ErrorCode2(com.akaxin.common.constant.ErrorCode2) UserGroupBean(com.akaxin.site.storage.bean.UserGroupBean) ApiGroupMuteProto(com.akaxin.proto.site.ApiGroupMuteProto) CommandResponse(com.akaxin.common.command.CommandResponse) ApiGroupSettingProto(com.akaxin.proto.site.ApiGroupSettingProto)

Aggregations

UserGroupBean (com.akaxin.site.storage.bean.UserGroupBean)6 CommandResponse (com.akaxin.common.command.CommandResponse)4 ErrorCode2 (com.akaxin.common.constant.ErrorCode2)4 ApiGroupSettingProto (com.akaxin.proto.site.ApiGroupSettingProto)2 ApiGroupUpdateSettingProto (com.akaxin.proto.site.ApiGroupUpdateSettingProto)2 ApiGroupMuteProto (com.akaxin.proto.site.ApiGroupMuteProto)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1