فهرست منبع

修改直播间观看权限-完成

hgw 3 سال پیش
والد
کامیت
26eb59cadc

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ImLiveRoomPurviewService.java

@@ -21,6 +21,14 @@ public interface ImLiveRoomPurviewService extends IService<ImLiveRoomPurview> {
     ImLiveRoomPurviewDao getDao();
 
     /**
+     * 添加观看权限数据
+     *
+     * @param ids     bizId
+     * @param roomUid 直播间UID
+     */
+    void add(String ids, String roomUid);
+
+    /**
      * 删除观看权限数据
      *
      * @param ids     bizId

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveBroadcastRoomServiceImpl.java

@@ -230,6 +230,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
                 }
             }
         }
+        param.put("userId", sysUser.getId());
         IPage<ImLiveBroadcastRoomVo> page = baseMapper.queryPage(pageInfo, param);
 
         // 查询预约人数

+ 34 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveRoomPurviewServiceImpl.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.service.impl;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.common.collect.Lists;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.ImLiveRoomPurviewDao;
@@ -12,6 +13,7 @@ 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;
@@ -22,10 +24,8 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 直播间的观看权限表(ImLiveRoomPurview)表服务实现类
@@ -42,12 +42,42 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
     private EmployeeService employeeService;
     @Autowired
     private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private ImLiveBroadcastRoomService imLiveBroadcastRoomService;
 
     public ImLiveRoomPurviewDao getDao() {
         return this.baseMapper;
     }
 
     /**
+     * 添加观看权限数据
+     *
+     * @param ids     bizId
+     * @param roomUid 直播间UID
+     */
+    @Override
+    public void add(String ids, String roomUid) {
+        Optional.ofNullable(roomUid).orElseThrow(() -> new BizException("房间uid不能为空"));
+        Optional.ofNullable(ids).orElseThrow(() -> new BizException("请选择要删除的数据"));
+        //查询房间类型
+        ImLiveBroadcastRoom room = imLiveBroadcastRoomService.getOne(Wrappers.<ImLiveBroadcastRoom>lambdaQuery()
+                .eq(ImLiveBroadcastRoom::getRoomUid, roomUid));
+        Date date = new Date();
+        Integer userId = getSysUser().getId();
+        List<String> strings = WrapperUtil.toList(ids);
+        List<ImLiveRoomPurview> collect = strings.stream().map(id -> {
+            ImLiveRoomPurview imLiveRoomPurview = new ImLiveRoomPurview();
+            imLiveRoomPurview.setRoomUid(roomUid);
+            imLiveRoomPurview.setBizId(id);
+            imLiveRoomPurview.setType(room.getPopularizeType());
+            imLiveRoomPurview.setCreatedBy(userId);
+            imLiveRoomPurview.setCreatedTime(date);
+            return imLiveRoomPurview;
+        }).collect(Collectors.toList());
+        Lists.partition(collect, 100).forEach(l -> baseMapper.insertBatch(l));
+    }
+
+    /**
      * 删除观看权限数据
      *
      * @param ids     bizId

+ 15 - 1
mec-biz/src/main/resources/config/mybatis/ImLiveBroadcastRoomMapper.xml

@@ -42,7 +42,7 @@
     </insert>
 
     <select id="queryPage" resultType="com.ym.mec.biz.dal.vo.ImLiveBroadcastRoomVo">
-        select a.id_ AS id,
+        select distinct a.id_ AS id,
         a.tenant_id_ AS tenantId,
         t.name_ AS tenantName,
         t.logo_ AS tenantLogo,
@@ -84,6 +84,20 @@
             where popularize_type_ = 'SCHOOL'
             and INTE_ARRAY(a.popularize_school_ids_, #{param.schoolIds}) = 1
         </if>
+        <if test="param.userId != null">
+            union all
+            select distinct r.* from im_live_broadcast_room as r inner join
+            im_live_room_purview as a on r.room_uid_ = a.room_uid_
+            where
+            r.popularize_type_= 'GROUP'
+            and a.biz_id_ in (
+            select
+            distinct a.id_
+            from
+            im_group a
+            inner join im_group_member b on a.id_=b.im_group_id_
+            where b.user_id_ = #{param.userId})
+        </if>
         ) as a
         left join tenant_info AS t on a.tenant_id_ = t.id_
         left join sys_user AS b on a.speaker_id_ = b.id_

+ 21 - 1
mec-biz/src/main/resources/config/mybatis/ImLiveRoomReservationMapper.xml

@@ -24,7 +24,7 @@
     </insert>
 
     <select id="queryPageStudent" resultType="com.ym.mec.biz.dal.vo.ImLiveBroadcastRoomVo">
-        select a.id_ AS id,
+        select distinct a.id_ AS id,
         a.tenant_id_ AS tenantId,
         t.name_ AS tenantName,
         t.logo_ AS tenantLogo,
@@ -67,6 +67,26 @@
             where popularize_type_ = 'TEAM'
             and INTE_ARRAY(a.popularize_team_ids_, #{param.teamIds}) = 1
         </if>
+        union all
+        select distinct r.* from im_live_broadcast_room as r inner join
+        im_live_room_purview as a on r.room_uid_ = a.room_uid_
+        where
+        r.popularize_type_= 'GROUP'
+        and a.biz_id_ in (
+        select
+        distinct a.id_
+        from
+        im_group a
+        inner join im_group_member b on a.id_=b.im_group_id_
+        where b.user_id_ = #{param.userId})
+        union all
+        select b.* from
+        (select
+        room_uid_ from im_live_room_purview where
+        CAST(biz_id_ AS SIGNED)  = #{param.userId}
+        and type_ = 'STUDENT') a
+        left join  im_live_broadcast_room b on a.room_uid_ = b.room_uid_
+        where b.popularize_type_ = 'STUDENT'
         ) as a
         left join tenant_info AS t on a.tenant_id_ = t.id_
         left join sys_user AS b on a.speaker_id_ = b.id_

+ 16 - 4
mec-web/src/main/java/com/ym/mec/web/controller/ImLiveRoomPurviewController.java

@@ -31,13 +31,25 @@ public class ImLiveRoomPurviewController extends BaseController {
     private ImLiveRoomPurviewService imLiveRoomPurviewService;
 
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "ids", dataType = "String", value = "删除的id,学员id,群id, 逗号分开"),
+            @ApiImplicitParam(name = "ids", dataType = "String", value = "删除的id,学员id,群id, 逗号分开", required = true),
+            @ApiImplicitParam(name = "roomUid", dataType = "String", value = "直播间UID", required = true),
+    })
+    @ApiOperation("删除观看权限数据")
+    @GetMapping("/add")
+    @PreAuthorize("@pcs.hasPermissions('imLiveRoomPurview/add')")
+    public HttpResponseResult<Object> add(String ids, String roomUid) {
+        imLiveRoomPurviewService.add(ids, roomUid);
+        return succeed();
+    }
+
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "ids", dataType = "String", value = "删除的id,学员id,群id, 逗号分开", required = true),
             @ApiImplicitParam(name = "roomUid", dataType = "String", value = "直播间UID", required = true),
     })
     @ApiOperation("删除观看权限数据")
     @GetMapping("/delete")
     @PreAuthorize("@pcs.hasPermissions('imLiveRoomPurview/delete')")
-    public HttpResponseResult<Object> delete(String ids, String roomUid){
+    public HttpResponseResult<Object> delete(String ids, String roomUid) {
         imLiveRoomPurviewService.delete(ids, roomUid);
         return succeed();
     }
@@ -66,7 +78,7 @@ public class ImLiveRoomPurviewController extends BaseController {
     @ApiOperation("查询当前直播间群聊列表-观看权限")
     @PostMapping("/queryGroup")
     @PreAuthorize("@pcs.hasPermissions('imLiveRoomPurview/queryGroup')")
-    public HttpResponseResult<PageInfo<ImGroup>> queryGroup(@RequestBody Map<String, Object> param){
+    public HttpResponseResult<PageInfo<ImGroup>> queryGroup(@RequestBody Map<String, Object> param) {
         return succeed(imLiveRoomPurviewService.queryGroup(param));
     }
 
@@ -94,7 +106,7 @@ public class ImLiveRoomPurviewController extends BaseController {
     @ApiOperation("选择列表-观看权限-群聊列表")
     @PostMapping("/selectRoomPurviewGroup")
     @PreAuthorize("@pcs.hasPermissions('imLiveRoomPurview/selectRoomPurviewGroup')")
-    public HttpResponseResult<PageInfo<ImGroup>> selectRoomPurviewGroup(@RequestBody Map<String, Object> param){
+    public HttpResponseResult<PageInfo<ImGroup>> selectRoomPurviewGroup(@RequestBody Map<String, Object> param) {
         return succeed(imLiveRoomPurviewService.selectRoomPurviewGroup(param));
     }