Search in sources :

Example 1 with UserFriendBean

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

the class SQLiteUserFriendDao method queryMute.

public boolean queryMute(String siteUserId, String siteFriendId) throws SQLException {
    long startTime = System.currentTimeMillis();
    String sql = "SELECT mute FROM " + USER_FRIEND_TABLE + " WHERE site_user_id=? AND site_friend_id=?;";
    UserFriendBean bean = null;
    PreparedStatement preState = SQLiteJDBCManager.getConnection().prepareStatement(sql);
    preState.setString(1, siteUserId);
    preState.setString(2, siteFriendId);
    ResultSet rs = preState.executeQuery();
    if (rs.next()) {
        return rs.getBoolean(1);
    }
    long endTime = System.currentTimeMillis();
    LogUtils.dbDebugLog(logger, startTime, bean, sql + siteUserId + "," + siteFriendId);
    return true;
}
Also used : ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) UserFriendBean(com.akaxin.site.storage.bean.UserFriendBean)

Example 2 with UserFriendBean

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

the class SQLiteUserFriendDao method queryUserFriendSetting.

public UserFriendBean queryUserFriendSetting(String siteUserId, String siteFriendId) throws SQLException {
    long startTime = System.currentTimeMillis();
    String sql = "SELECT mute FROM " + USER_FRIEND_TABLE + " WHERE site_user_id=? AND site_friend_id=?;";
    UserFriendBean bean = null;
    PreparedStatement preState = SQLiteJDBCManager.getConnection().prepareStatement(sql);
    preState.setString(1, siteUserId);
    preState.setString(2, siteFriendId);
    ResultSet rs = preState.executeQuery();
    if (rs.next()) {
        bean = new UserFriendBean();
        bean.setMute(rs.getBoolean(1));
    }
    LogUtils.dbDebugLog(logger, startTime, bean, sql, siteUserId, siteFriendId);
    return bean;
}
Also used : ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) UserFriendBean(com.akaxin.site.storage.bean.UserFriendBean)

Example 3 with UserFriendBean

use of com.akaxin.site.storage.bean.UserFriendBean 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 4 with UserFriendBean

use of com.akaxin.site.storage.bean.UserFriendBean 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)

Example 5 with UserFriendBean

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

the class UserFriendDao method getFriendSetting.

public UserFriendBean getFriendSetting(String siteUserId, String siteFriendId) {
    try {
        UserFriendBean bean = userFriendDao.getFriendSetting(siteUserId, siteFriendId);
        if (bean == null) {
            bean = new UserFriendBean();
            bean.setMute(false);
        }
        return bean;
    } catch (SQLException e) {
        logger.error("get friend setting error", e);
    }
    return null;
}
Also used : SQLException(java.sql.SQLException) UserFriendBean(com.akaxin.site.storage.bean.UserFriendBean)

Aggregations

UserFriendBean (com.akaxin.site.storage.bean.UserFriendBean)5 CommandResponse (com.akaxin.common.command.CommandResponse)2 ErrorCode2 (com.akaxin.common.constant.ErrorCode2)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 ApiFriendSettingProto (com.akaxin.proto.site.ApiFriendSettingProto)1 ApiFriendUpdateSettingProto (com.akaxin.proto.site.ApiFriendUpdateSettingProto)1 SQLException (java.sql.SQLException)1