//查询这些成员的IM账号
List<TUser> tUsers = tCircleMemberMapper.selImAccountByCircleId(circleId);
PojoGroupInfo pojoGroupInfo = new PojoGroupInfo();
pojoGroupInfo.setName(tCircle.getCircleName());
pojoGroupInfo.setOwner(tUser.getImAccount());
pojoGroupInfo.setPortrait(tCircle.getCircleThumb());
ArrayList<PojoGroupMember> pojoGroupMembers = new ArrayList<>();
for (TUser user : tUsers) {
PojoGroupMember pojoGroupMember = new PojoGroupMember();
pojoGroupMember.setMember_id(user.getImAccount());
pojoGroupMembers.add(pojoGroupMember);
}
try {
IMResult<OutputCreateGroupResult> group = GroupAdmin.createGroup(tUser.getImAccount(), pojoGroupInfo, pojoGroupMembers, null, null);
if (group.getCode() != 0) {
throw new RuntimeException("创建群组失败");
}
//更新群组信息到圈子中
tCircle.setGroupId(group.getResult().getGroup_id());
int i = updateTCircle(tCircle);
if (i > 0) {
return success("创建群组成功");
}
throw new RuntimeException("创建群组失败");
} catch (Exception e) {
throw new RuntimeException(e);
}