|
@@ -8,17 +8,17 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.ImLiveRoomPurviewDao;
|
|
|
import com.ym.mec.biz.dal.dto.SysUserDto;
|
|
|
-import com.ym.mec.biz.dal.entity.Employee;
|
|
|
import com.ym.mec.biz.dal.entity.ImGroup;
|
|
|
import com.ym.mec.biz.dal.entity.ImLiveBroadcastRoom;
|
|
|
import com.ym.mec.biz.dal.entity.ImLiveRoomPurview;
|
|
|
-import com.ym.mec.biz.service.EmployeeService;
|
|
|
import com.ym.mec.biz.service.ImLiveBroadcastRoomService;
|
|
|
import com.ym.mec.biz.service.ImLiveRoomPurviewService;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.page.PageUtil;
|
|
|
import com.ym.mec.common.page.WrapperUtil;
|
|
|
+import com.ym.mec.common.tenant.TenantContextHolder;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* 直播间的观看权限表(ImLiveRoomPurview)表服务实现类
|
|
@@ -39,8 +40,6 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
|
|
|
private final static Logger log = LoggerFactory.getLogger(ImLiveRoomPurviewServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
|
- private EmployeeService employeeService;
|
|
|
- @Autowired
|
|
|
private SysUserFeignService sysUserFeignService;
|
|
|
@Autowired
|
|
|
private ImLiveBroadcastRoomService imLiveBroadcastRoomService;
|
|
@@ -50,7 +49,32 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 添加观看权限数据
|
|
|
+ * 批量添加/根据查询条件添加房间观看权限
|
|
|
+ *
|
|
|
+ * @param param 参数
|
|
|
+ * <p> - search 搜索关键字
|
|
|
+ * <p> - subjectId 声部ID
|
|
|
+ * <p> - organIds 分部ID
|
|
|
+ * <p> - groupIds 群聊ID
|
|
|
+ * <p> - teamIds 乐团ID
|
|
|
+ * <p> - schoolIds 学校id/合作单位id
|
|
|
+ * <p> - roomUid 直播间UID
|
|
|
+ */
|
|
|
+ public void addByCondition(Map<String, Object> param) {
|
|
|
+ String roomUid = WrapperUtil.toStr(param, "roomUid", "房间uid不能为空");
|
|
|
+ param.put("tenantId", TenantContextHolder.getTenantId());
|
|
|
+ //根据条件查询学员
|
|
|
+ List<SysUserDto> studentList = baseMapper.selectRoomPurviewStudent(param);
|
|
|
+ if (CollectionUtils.isEmpty(studentList)) {
|
|
|
+ throw new BizException("没有查询到人员信息");
|
|
|
+ }
|
|
|
+ Stream<Integer> userIdList = studentList.stream().map(SysUserDto::getUserId).map(Long::intValue);
|
|
|
+ //添加学员
|
|
|
+ batchInsert(userIdList, roomUid, "STUDENT");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 指定多个学员id添加观看权限数据
|
|
|
*
|
|
|
* @param ids bizId
|
|
|
* @param roomUid 直播间UID
|
|
@@ -58,18 +82,37 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
|
|
|
@Override
|
|
|
public void add(String ids, String roomUid) {
|
|
|
Optional.ofNullable(roomUid).orElseThrow(() -> new BizException("房间uid不能为空"));
|
|
|
- Optional.ofNullable(ids).orElseThrow(() -> new BizException("请选择要删除的数据"));
|
|
|
+ Optional.ofNullable(ids)
|
|
|
+ .filter(WrapperUtil.StrPredicate)
|
|
|
+ .orElseThrow(() -> new BizException("请选择要删除的数据"));
|
|
|
//查询房间类型
|
|
|
ImLiveBroadcastRoom room = imLiveBroadcastRoomService.getOne(Wrappers.<ImLiveBroadcastRoom>lambdaQuery()
|
|
|
.eq(ImLiveBroadcastRoom::getRoomUid, roomUid));
|
|
|
+ if (Objects.isNull(room)) {
|
|
|
+ throw new BizException("房间不存在");
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(room.getPopularizeType()) && Objects.equals(room.getPopularizeType(), ImLiveBroadcastRoom.ALL)) {
|
|
|
+ throw new BizException("该直播间为公开类型的直播间,不能添加观看权限");
|
|
|
+ }
|
|
|
+ //添加学员
|
|
|
+ List<Integer> userIdList = WrapperUtil.splitToIntList(ids);
|
|
|
+ if (CollectionUtils.isEmpty(userIdList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ batchInsert(userIdList.stream(), roomUid, "STUDENT");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void batchInsert(Stream<Integer> stream, String roomUid, String type) {
|
|
|
+ if (Objects.isNull(stream)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
Date date = new Date();
|
|
|
Integer userId = getSysUser().getId();
|
|
|
- List<String> strings = WrapperUtil.toList(ids);
|
|
|
- List<ImLiveRoomPurview> collect = strings.stream().map(id -> {
|
|
|
+ List<ImLiveRoomPurview> collect = stream.map(id -> {
|
|
|
ImLiveRoomPurview imLiveRoomPurview = new ImLiveRoomPurview();
|
|
|
imLiveRoomPurview.setRoomUid(roomUid);
|
|
|
- imLiveRoomPurview.setBizId(id);
|
|
|
- imLiveRoomPurview.setType(room.getPopularizeType());
|
|
|
+ imLiveRoomPurview.setUserId(id);
|
|
|
+ imLiveRoomPurview.setType(type);
|
|
|
imLiveRoomPurview.setCreatedBy(userId);
|
|
|
imLiveRoomPurview.setCreatedTime(date);
|
|
|
return imLiveRoomPurview;
|
|
@@ -87,9 +130,9 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
|
|
|
public void delete(String ids, String roomUid) {
|
|
|
Optional.ofNullable(roomUid).orElseThrow(() -> new BizException("房间uid不能为空"));
|
|
|
Optional.ofNullable(ids).orElseThrow(() -> new BizException("请选择要删除的数据"));
|
|
|
- List<String> strings = WrapperUtil.toList(ids);
|
|
|
+ List<Integer> userIdList = WrapperUtil.splitToIntList(ids);
|
|
|
this.remove(Wrappers.<ImLiveRoomPurview>lambdaQuery()
|
|
|
- .in(ImLiveRoomPurview::getBizId, strings)
|
|
|
+ .in(ImLiveRoomPurview::getUserId, userIdList)
|
|
|
.eq(ImLiveRoomPurview::getRoomUid, roomUid));
|
|
|
}
|
|
|
|
|
@@ -99,6 +142,10 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
|
|
|
* @param param 参数
|
|
|
* <p> - search 搜索关键字
|
|
|
* <p> - subjectId 声部ID
|
|
|
+ * <p> - organIds 分部ID
|
|
|
+ * <p> - groupIds 群聊ID
|
|
|
+ * <p> - teamIds 乐团ID
|
|
|
+ * <p> - schoolIds 学校id/合作单位id
|
|
|
* <p> - roomUid 直播间UID
|
|
|
* <p> -page 页数
|
|
|
* <p> -rows 每页数量
|
|
@@ -106,23 +153,11 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
|
|
|
@Override
|
|
|
public PageInfo<SysUserDto> queryStudent(Map<String, Object> param) {
|
|
|
WrapperUtil.toStr(param, "roomUid", "房间uid不能为空");
|
|
|
+ param.put("in", 1);
|
|
|
+ param.put("tenantId", TenantContextHolder.getTenantId());
|
|
|
Page<SysUserDto> pageInfo = PageUtil.getPageInfo(param);
|
|
|
- return PageUtil.pageInfo(baseMapper.queryStudent(pageInfo, param));
|
|
|
- }
|
|
|
+ return PageUtil.pageInfo(baseMapper.selectRoomPurviewStudent(pageInfo, param));
|
|
|
|
|
|
- /**
|
|
|
- * 查询群聊列表-观看权限
|
|
|
- *
|
|
|
- * @param param 参数
|
|
|
- * <p> - search 搜索关键字
|
|
|
- * <p> - roomUid 直播间UID
|
|
|
- * <p> - groupType 群类型
|
|
|
- */
|
|
|
- @Override
|
|
|
- public PageInfo<ImGroup> queryGroup(Map<String, Object> param) {
|
|
|
- WrapperUtil.toStr(param, "roomUid", "房间uid不能为空");
|
|
|
- param.put("in", 1);
|
|
|
- return getImGroupPageInfo(param);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -131,6 +166,10 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
|
|
|
* @param param 参数
|
|
|
* <p> - search 搜索关键字
|
|
|
* <p> - subjectId 声部ID
|
|
|
+ * <p> - organIds 分部ID
|
|
|
+ * <p> - groupIds 群聊ID
|
|
|
+ * <p> - teamIds 乐团ID
|
|
|
+ * <p> - schoolIds 学校id/合作单位id
|
|
|
* <p> - roomUid 直播间UID
|
|
|
* <p> -page 页数
|
|
|
* <p> -rows 每页数量
|
|
@@ -138,17 +177,8 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
|
|
|
@Override
|
|
|
public PageInfo<SysUserDto> selectRoomPurviewStudent(Map<String, Object> param) {
|
|
|
WrapperUtil.toStr(param, "roomUid", "房间uid不能为空");
|
|
|
+ param.put("tenantId", TenantContextHolder.getTenantId());
|
|
|
Page<SysUserDto> pageInfo = PageUtil.getPageInfo(param);
|
|
|
- //查询当前登录人分部
|
|
|
- SysUser sysUser = getSysUser();
|
|
|
- //分部id
|
|
|
- String organIds = null;
|
|
|
- Employee employee = employeeService.get(sysUser.getId());
|
|
|
- if (Objects.nonNull(employee) && Objects.nonNull(employee.getOrganIdList())) {
|
|
|
- organIds = employee.getOrganIdList();
|
|
|
- }
|
|
|
- param.put("organId", organIds);
|
|
|
- param.put("type", ImLiveBroadcastRoom.STUDENT);
|
|
|
return PageUtil.pageInfo(baseMapper.selectRoomPurviewStudent(pageInfo, param));
|
|
|
}
|
|
|
|
|
@@ -162,16 +192,9 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
|
|
|
*/
|
|
|
@Override
|
|
|
public PageInfo<ImGroup> selectRoomPurviewGroup(Map<String, Object> param) {
|
|
|
- WrapperUtil.toStr(param, "roomUid", "房间uid不能为空");
|
|
|
- param.put("notIn", 1);
|
|
|
- return getImGroupPageInfo(param);
|
|
|
- }
|
|
|
-
|
|
|
- private PageInfo<ImGroup> getImGroupPageInfo(Map<String, Object> param) {
|
|
|
//查询当前登录人分部
|
|
|
SysUser sysUser = getSysUser();
|
|
|
param.put("userId", sysUser.getId());
|
|
|
- param.put("type", ImLiveBroadcastRoom.GROUP);
|
|
|
Page<ImGroup> pageInfo = PageUtil.getPageInfo(param);
|
|
|
return PageUtil.pageInfo(baseMapper.selectRoomPurviewGroup(pageInfo, param));
|
|
|
}
|