Search in sources :

Example 6 with GroupProfileBean

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

the class HttpGroupService method profile.

/**
 * 获取群资料
 *
 * @param command
 * @return
 */
public CommandResponse profile(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        HaiGroupProfileProto.HaiGroupProfileRequest request = HaiGroupProfileProto.HaiGroupProfileRequest.parseFrom(command.getParams());
        String groupId = request.getGroupId();
        LogUtils.requestDebugLog(logger, command, request.toString());
        GroupProfileBean groupBean = UserGroupDao.getInstance().getGroupProfile(groupId);
        if (groupBean != null && StringUtils.isNotBlank(groupBean.getGroupId())) {
            GroupProto.GroupProfile groupProfile = GroupProto.GroupProfile.newBuilder().setId(groupBean.getGroupId()).setName(String.valueOf(groupBean.getGroupName())).setIcon(String.valueOf(groupBean.getGroupPhoto())).build();
            HaiGroupProfileProto.HaiGroupProfileResponse.Builder responseBuilder = HaiGroupProfileProto.HaiGroupProfileResponse.newBuilder();
            responseBuilder.setProfile(groupProfile);
            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 : ErrorCode2(com.akaxin.common.constant.ErrorCode2) GroupProto(com.akaxin.proto.core.GroupProto) HaiGroupProfileProto(com.akaxin.proto.plugin.HaiGroupProfileProto) CommandResponse(com.akaxin.common.command.CommandResponse) GroupProfileBean(com.akaxin.site.storage.bean.GroupProfileBean)

Example 7 with GroupProfileBean

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

the class UserGroupDao method createGroup.

// 创建群
public GroupProfileBean createGroup(String createUserId, String groupName, List<String> userIds) {
    GroupProfileBean bean = new GroupProfileBean();
    try {
        bean.setCreateTime(System.currentTimeMillis());
        bean.setGroupName(groupName);
        bean.setCreateUserId(createUserId);
        // 群头像使用默认
        // bean.setGroupPhoto(GROUP_DEFAULT_ICON);
        bean.setGroupStatus(GroupProto.GroupStatus.GROUP_NORMAL_VALUE);
        // 1.创建群资料
        bean = groupDao.addGroupProfile(bean);
        // 2.添加群成员入库
        for (String memberId : userIds) {
            int status = GroupProto.GroupMemberRole.MEMBER_VALUE;
            if (createUserId.equals(memberId)) {
                status = GroupProto.GroupMemberRole.OWNER_VALUE;
            }
            groupDao.addGroupMember(memberId, bean.getGroupId(), status);
        }
        // 3.群消息中发送通知
        new GroupNotice().newGroupMemberNotice(createUserId, bean.getGroupId(), userIds);
    } catch (Exception e) {
        logger.error("create group error.", e);
    }
    return bean;
}
Also used : GroupNotice(com.akaxin.site.business.impl.notice.GroupNotice) GroupProfileBean(com.akaxin.site.storage.bean.GroupProfileBean) SQLException(java.sql.SQLException)

Example 8 with GroupProfileBean

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

the class SQLiteGroupProfileDao method queryGroupProfile.

public GroupProfileBean queryGroupProfile(String siteGroupId) throws SQLException {
    long startTime = System.currentTimeMillis();
    GroupProfileBean profileBean = null;
    String sql = "SELECT site_group_id,group_name,group_photo,group_notice,ts_status,create_user_id,group_status,close_invite_group_chat,create_time FROM " + GROUP_PROFILE_TABLE + " WHERE site_group_id=?;";
    PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
    preStatement.setString(1, siteGroupId);
    ResultSet rs = preStatement.executeQuery();
    if (rs.next()) {
        profileBean = new GroupProfileBean();
        profileBean.setGroupId(rs.getString(1));
        profileBean.setGroupName(rs.getString(2));
        profileBean.setGroupPhoto(rs.getString(3));
        profileBean.setGroupNotice(rs.getString(4));
        profileBean.setTsStatus(rs.getInt(5));
        profileBean.setCreateUserId(rs.getString(6));
        profileBean.setGroupStatus(rs.getInt(7));
        profileBean.setCloseInviteGroupChat(rs.getBoolean(8));
        profileBean.setCreateTime(rs.getLong(9));
    }
    LogUtils.dbDebugLog(logger, startTime, profileBean, sql, siteGroupId);
    return profileBean;
}
Also used : ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) GroupProfileBean(com.akaxin.site.storage.bean.GroupProfileBean)

Example 9 with GroupProfileBean

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

the class SQLiteGroupProfileDao method querySimpleGroupProfile.

public GroupProfileBean querySimpleGroupProfile(String siteGroupId) throws SQLException {
    long startTime = System.currentTimeMillis();
    GroupProfileBean profileBean = null;
    String sql = "SELECT site_group_id,group_name,group_photo FROM " + GROUP_PROFILE_TABLE + " WHERE site_group_id=?;";
    PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
    preStatement.setString(1, siteGroupId);
    ResultSet rs = preStatement.executeQuery();
    if (rs.next()) {
        profileBean = new GroupProfileBean();
        profileBean.setGroupId(rs.getString(1));
        profileBean.setGroupName(rs.getString(2));
        profileBean.setGroupPhoto(rs.getString(3));
    }
    LogUtils.dbDebugLog(logger, startTime, profileBean, sql, siteGroupId);
    return profileBean;
}
Also used : ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) GroupProfileBean(com.akaxin.site.storage.bean.GroupProfileBean)

Aggregations

GroupProfileBean (com.akaxin.site.storage.bean.GroupProfileBean)9 CommandResponse (com.akaxin.common.command.CommandResponse)6 ErrorCode2 (com.akaxin.common.constant.ErrorCode2)6 GroupProto (com.akaxin.proto.core.GroupProto)2 ProtocolStringList (com.google.protobuf.ProtocolStringList)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 UserProto (com.akaxin.proto.core.UserProto)1 HaiGroupProfileProto (com.akaxin.proto.plugin.HaiGroupProfileProto)1 HaiGroupUpdateProfileProto (com.akaxin.proto.plugin.HaiGroupUpdateProfileProto)1 ApiGroupAddMemberProto (com.akaxin.proto.site.ApiGroupAddMemberProto)1 ApiGroupCreateProto (com.akaxin.proto.site.ApiGroupCreateProto)1 ApiGroupProfileProto (com.akaxin.proto.site.ApiGroupProfileProto)1 ApiGroupUpdateProfileProto (com.akaxin.proto.site.ApiGroupUpdateProfileProto)1 GroupNotice (com.akaxin.site.business.impl.notice.GroupNotice)1 GroupMemberBean (com.akaxin.site.storage.bean.GroupMemberBean)1 SimpleUserBean (com.akaxin.site.storage.bean.SimpleUserBean)1 SQLException (java.sql.SQLException)1