|
@@ -2,7 +2,6 @@ package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -17,6 +16,7 @@ import com.ym.mec.biz.dal.dao.LiveGoodsMapperDao;
|
|
|
import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
|
import com.ym.mec.biz.dal.dto.ImLiveBroadcastRoomDto;
|
|
|
import com.ym.mec.biz.dal.dto.RoomReservationUserSearch;
|
|
|
+import com.ym.mec.biz.dal.dto.SysUserDto;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
|
import com.ym.mec.biz.dal.page.LiveRoomGoodsOrderQueryInfo;
|
|
@@ -92,8 +92,6 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
private ImLiveRoomBlackService imLiveRoomBlackService;
|
|
|
@Autowired
|
|
|
private EmployeeService employeeService;
|
|
|
- @Autowired
|
|
|
- private ImLiveRoomPurviewService imLiveRoomPurviewService;
|
|
|
|
|
|
//待替换的变量
|
|
|
public static final String USER_ID = "${userId}";
|
|
@@ -217,25 +215,6 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
Page<ImLiveBroadcastRoomVo> pageInfo = PageUtil.concatTimePage(param, "startTime", "endTime");
|
|
|
pageInfo.setDesc("a.created_time_");
|
|
|
param.put("tenantId", TenantContextHolder.getTenantId());
|
|
|
- //查询该人员分部 及 分部下包含的学校(合作单位)
|
|
|
- SysUser sysUser = getSysUser();
|
|
|
- //分部
|
|
|
- String organIds;
|
|
|
- //如果是超管就查询当前机构所有的直播间
|
|
|
- if (sysUser.getTenantId() == -1 || sysUser.getIsSuperAdmin()) {
|
|
|
- param.put("allRoom", 1);
|
|
|
- } else {
|
|
|
- Employee employee = employeeService.get(sysUser.getId());
|
|
|
- if (Objects.nonNull(employee) && Objects.nonNull(employee.getOrganIdList())) {
|
|
|
- organIds = employee.getOrganIdList();
|
|
|
- param.put("organIds", organIds);
|
|
|
- String schoolIds = baseMapper.querySchoolIds(organIds);
|
|
|
- if (StringUtils.isNotBlank(schoolIds)) {
|
|
|
- param.put("schoolIds", schoolIds);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- param.put("userId", sysUser.getId());
|
|
|
IPage<ImLiveBroadcastRoomVo> page = baseMapper.queryPage(pageInfo, param);
|
|
|
|
|
|
// 查询预约人数
|
|
@@ -267,7 +246,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public ImLiveBroadcastRoomVo add(ImLiveBroadcastRoomDto dto) {
|
|
|
+ public void add(ImLiveBroadcastRoomDto dto) {
|
|
|
SysUser sysUser = getSysUser(dto.getSpeakerId());
|
|
|
Date now = new Date();
|
|
|
if (now.getTime() > dto.getLiveStartTime().getTime()) {
|
|
@@ -284,7 +263,6 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
obj.setCreatedBy(getSysUser().getId());
|
|
|
obj.setCreatedTime(now);
|
|
|
this.save(obj);
|
|
|
- return getImLiveBroadcastRoomVo(roomUid);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -294,7 +272,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public ImLiveBroadcastRoomVo update(ImLiveBroadcastRoomDto dto) {
|
|
|
+ public void update(ImLiveBroadcastRoomDto dto) {
|
|
|
Date now = new Date();
|
|
|
Integer userId = getSysUser().getId();
|
|
|
ImLiveBroadcastRoom obj = this.getById(dto.getId());
|
|
@@ -304,94 +282,16 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
if (obj.getLiveState() == 1) {
|
|
|
obj.setRoomConfig(JSONObject.toJSONString(dto.getRoomConfig()));
|
|
|
this.updateById(obj);
|
|
|
- return getImLiveBroadcastRoomVo(obj.getRoomUid());
|
|
|
+ return;
|
|
|
}
|
|
|
if (now.getTime() > dto.getLiveStartTime().getTime()) {
|
|
|
throw new BizException("设置的直播开始时间不能小于当前时间");
|
|
|
}
|
|
|
//本次修改后的类型
|
|
|
- String popularizeType = dto.getPopularizeType();
|
|
|
BeanUtils.copyProperties(dto, obj);
|
|
|
- //修改-删除直播可见权限部分数据
|
|
|
- deleteRoomPurview(obj, popularizeType);
|
|
|
- //添加直播间可见权限-只处理了群组和学生可是权限-其他的走原来的方式
|
|
|
- insertGroupStudentPurview(dto, userId, obj.getRoomUid());
|
|
|
-
|
|
|
obj.setRoomConfig(JSONObject.toJSONString(dto.getRoomConfig()));
|
|
|
log.info("update room >>> :{}", JSONObject.toJSONString(obj));
|
|
|
this.updateById(obj);
|
|
|
- return getImLiveBroadcastRoomVo(obj.getRoomUid());
|
|
|
- }
|
|
|
-
|
|
|
- //添加直播间可见权限-只处理了群组和学生可是权限
|
|
|
- private void insertGroupStudentPurview(ImLiveBroadcastRoomDto dto, Integer userId, String roomUid) {
|
|
|
- Date now = new Date();
|
|
|
- if (WrapperUtil.checkStr(dto.getPopularizeType(), ImLiveBroadcastRoom.GROUP, ImLiveBroadcastRoom.STUDENT)) {
|
|
|
- List<String> bizIdList = new ArrayList<>();
|
|
|
- if (ImLiveBroadcastRoom.GROUP.equals(dto.getPopularizeType())) {
|
|
|
- bizIdList = WrapperUtil.toList(dto.getPopularizeGroupIds());
|
|
|
- }
|
|
|
- if (ImLiveBroadcastRoom.STUDENT.equals(dto.getPopularizeType())) {
|
|
|
- bizIdList = WrapperUtil.toList(dto.getPopularizeStudentIds());
|
|
|
- }
|
|
|
- if (CollectionUtils.isEmpty(bizIdList)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- List<ImLiveRoomPurview> collect = bizIdList.stream().map((id) -> {
|
|
|
- ImLiveRoomPurview imLiveRoomPurview = new ImLiveRoomPurview();
|
|
|
- imLiveRoomPurview.setRoomUid(roomUid);
|
|
|
- imLiveRoomPurview.setBizId(id);
|
|
|
- imLiveRoomPurview.setType(dto.getPopularizeType());
|
|
|
- imLiveRoomPurview.setCreatedBy(userId);
|
|
|
- imLiveRoomPurview.setCreatedTime(now);
|
|
|
- return imLiveRoomPurview;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- Lists.partition(collect, 50).forEach(list -> imLiveRoomPurviewService.saveBatch(list));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void deleteRoomPurview(ImLiveBroadcastRoom obj, String popularizeType) {
|
|
|
- LambdaQueryWrapper<ImLiveRoomPurview> queryWrapper = null;
|
|
|
- switch (popularizeType) {
|
|
|
- case ImLiveBroadcastRoom.ALL:
|
|
|
- obj.setPopularizeOrgIds(null);
|
|
|
- obj.setPopularizeSchoolIds(null);
|
|
|
- obj.setPopularizeTeamIds(null);
|
|
|
- //删除purview表的数据
|
|
|
- queryWrapper = Wrappers.lambdaQuery();
|
|
|
- break;
|
|
|
- case ImLiveBroadcastRoom.ORGAN:
|
|
|
- obj.setPopularizeSchoolIds(null);
|
|
|
- obj.setPopularizeTeamIds(null);
|
|
|
- //删除purview表中不等于分部的数据
|
|
|
- queryWrapper = Wrappers.<ImLiveRoomPurview>lambdaQuery()
|
|
|
- .ne(ImLiveRoomPurview::getType, ImLiveBroadcastRoom.ORGAN);
|
|
|
- break;
|
|
|
- case ImLiveBroadcastRoom.SCHOOL:
|
|
|
- obj.setPopularizeTeamIds(null);
|
|
|
- //删除purview表中对应的数据
|
|
|
- queryWrapper = Wrappers.<ImLiveRoomPurview>lambdaQuery()
|
|
|
- .in(ImLiveRoomPurview::getType, ImLiveBroadcastRoom.TEAM, ImLiveBroadcastRoom.GROUP,
|
|
|
- ImLiveBroadcastRoom.STUDENT);
|
|
|
- break;
|
|
|
- case ImLiveBroadcastRoom.TEAM:
|
|
|
- queryWrapper = Wrappers.<ImLiveRoomPurview>lambdaQuery()
|
|
|
- .in(ImLiveRoomPurview::getType, ImLiveBroadcastRoom.SCHOOL, ImLiveBroadcastRoom.GROUP,
|
|
|
- ImLiveBroadcastRoom.STUDENT);
|
|
|
- break;
|
|
|
- case ImLiveBroadcastRoom.GROUP:
|
|
|
- queryWrapper = Wrappers.<ImLiveRoomPurview>lambdaQuery()
|
|
|
- .ne(ImLiveRoomPurview::getType, ImLiveBroadcastRoom.GROUP);
|
|
|
- break;
|
|
|
- case ImLiveBroadcastRoom.STUDENT:
|
|
|
- queryWrapper = Wrappers.<ImLiveRoomPurview>lambdaQuery()
|
|
|
- .ne(ImLiveRoomPurview::getType, ImLiveBroadcastRoom.STUDENT);
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- if (Objects.nonNull(queryWrapper)) {
|
|
|
- imLiveRoomPurviewService.remove(queryWrapper.eq(ImLiveRoomPurview::getRoomUid, obj.getRoomUid()));
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1220,10 +1120,21 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
.orElseThrow(() -> new BizException("用户不存在."));
|
|
|
}
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ImLiveRoomPurviewService imLiveRoomPurviewService;
|
|
|
+
|
|
|
/**
|
|
|
* 测试
|
|
|
*/
|
|
|
public Map<String, Object> test(String roomUid) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ TenantContextHolder.setTenantId(1);
|
|
|
+ map.put("roomUid", roomUid);
|
|
|
+ map.put("groupIds", "22053019304300001,1141,1");
|
|
|
+ map.put("subjectIds", "2,5,4");
|
|
|
+ PageInfo<SysUserDto> sysUserDtoPageInfo = imLiveRoomPurviewService.selectRoomPurviewStudent(map);
|
|
|
+ System.out.println(sysUserDtoPageInfo);
|
|
|
+
|
|
|
//test
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
//校验房间心跳是否过期没续租
|