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);
}
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;
}
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;
}
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;
}
Aggregations