wangliang 4 anni fa
parent
commit
4c96f689ea

+ 7 - 2
themis-backend/src/main/java/com/qmth/themis/backend/api/SysController.java

@@ -248,8 +248,13 @@ public class SysController {
     @ApiOperation(value = "考试批次查询接口")
     @RequestMapping(value = "/exam/query", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "角色信息", response = TEExamQueryDto.class)})
-    public Result examQuery() {
-        List<TEExam> teExamList = teExamService.list();
+    public Result examQuery(@ApiParam(value = "用户id", required = false) @RequestParam(required = false) Long userId) {
+        List<TEExam> teExamList = null;
+        if (Objects.nonNull(userId) && !Objects.equals(userId, "")) {
+            teExamList = teExamService.examPrivilegeQuery(userId);
+        } else {
+            teExamList = teExamService.list();
+        }
         List<TEExamQueryDto> teExamQueryDtoList = null;
         if (Objects.nonNull(teExamList)) {
             Gson gson = new Gson();

+ 32 - 0
themis-backend/src/main/java/com/qmth/themis/backend/api/TIeInvigilateCallMobileController.java

@@ -6,16 +6,22 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.base.BasePage;
+import com.qmth.themis.business.bean.mobile.MobileAuthorizationMonitorBean;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.cache.RedisKeyHelper;
 import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.dto.MqDto;
+import com.qmth.themis.business.entity.TBSession;
+import com.qmth.themis.business.entity.TBUser;
 import com.qmth.themis.business.entity.TIeExamInvigilateCall;
 import com.qmth.themis.business.entity.TIeExamInvigilateCallLog;
 import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.service.MqDtoService;
 import com.qmth.themis.business.service.TIeExamInvigilateCallService;
 import com.qmth.themis.business.util.RedisUtil;
+import com.qmth.themis.business.util.ServletUtil;
+import com.qmth.themis.business.util.TencentYunUtil;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
@@ -28,6 +34,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
 
@@ -53,6 +60,9 @@ public class TIeInvigilateCallMobileController {
     @Resource
     TIeExamInvigilateCallService tIeExamInvigilateCallService;
 
+    @Resource
+    TencentYunUtil tencentYunUtil;
+
     @ApiOperation(value = "监考监控通话查询接口")
     @RequestMapping(value = "/call/list", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "监考监控信息", response = TIeExamInvigilateCall.class)})
@@ -107,4 +117,26 @@ public class TIeInvigilateCallMobileController {
         //监考监控通话信息 发送mq end
         return ResultUtil.ok(Collections.singletonMap("success", true));
     }
+
+    @ApiOperation(value = "监考获取monitorKey接口")
+    @RequestMapping(value = "/getMonitorKey", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "获取监考monitorKey", response = MobileAuthorizationMonitorBean.class)})
+    public Result getMonitorKey(@ApiParam(value = "考试记录id", required = true) @RequestParam Long recordId) {
+        TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+        TBSession tbSession = (TBSession) ServletUtil.getRequestSession();
+        String monitorKey = ExamRecordCacheUtil.getMonitorKey(recordId);
+        AuthDto authDto = (AuthDto) redisUtil.get(SystemConstant.userOauth + "::" + tbUser.getId());
+        String monitorUserId = null;
+        if (Objects.nonNull(authDto) && authDto.toString().contains(RoleEnum.STUDENT.name())) {
+            monitorUserId = "s_" + tbSession.getId();
+        } else {
+            monitorUserId = "m_" + tbSession.getId();
+        }
+        String monitorUserSig = tencentYunUtil.getSign(monitorUserId, SystemConstant.TENCENT_EXPIRE_TIME);
+        Map<String, Object> map = new HashMap<>();
+        map.put("monitorKey", monitorKey);
+        map.put("monitorUserId", monitorUserId);
+        map.put("monitorUserSig", monitorUserSig);
+        return ResultUtil.ok(map);
+    }
 }

+ 8 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TEExamMapper.java

@@ -59,4 +59,12 @@ public interface TEExamMapper extends BaseMapper<TEExam> {
      * @return
      */
     public IPage<TEExamQueryDto> examList(IPage<Map> iPage, @Param("orgId") Long orgId);
+
+    /**
+     * 考试批次权限过滤
+     *
+     * @param userId
+     * @return
+     */
+    public List<TEExam> examPrivilegeQuery(@Param("userId") Long userId);
 }

+ 8 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TEExamService.java

@@ -184,4 +184,12 @@ public interface TEExamService extends IService<TEExam> {
      * @param mqDto
      */
     public void sendOeLogMessage(SystemOperationEnum systemOperationEnum, Long examStudentId, Long recordId, MqDto mqDto);
+
+    /**
+     * 考试批次权限过滤
+     *
+     * @param userId
+     * @return
+     */
+    public List<TEExam> examPrivilegeQuery(Long userId);
 }

+ 11 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java

@@ -875,6 +875,17 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         //mq发送消息end
     }
 
+    /**
+     * 考试批次权限过滤
+     *
+     * @param userId
+     * @return
+     */
+    @Override
+    public List<TEExam> examPrivilegeQuery(Long userId) {
+        return teExamMapper.examPrivilegeQuery(userId);
+    }
+
     /**
      * 缓存操作
      *

+ 15 - 0
themis-business/src/main/resources/db/init.sql

@@ -504,6 +504,7 @@ INSERT INTO `t_b_privilege` VALUES (138, '拍照/录音提交', '/api/mobile/ans
 INSERT INTO `t_b_privilege` VALUES (139, '监考端撤销通话申请', '/api/admin/monitor/call/cancel', 'LINK', 10, 5, NULL, '2020-08-01 12:08:31');
 INSERT INTO `t_b_privilege` VALUES (140, '结束监考', '/api/admin/invigilate/exam/finish', 'LINK', 14, 12, NULL, '2020-08-01 12:08:31');
 INSERT INTO `t_b_privilege` VALUES (141, '导入导出任务', 'ImportExportTask', 'MENU', 4, 7, NULL, '2020-08-01 12:08:31');
+INSERT INTO `t_b_privilege` VALUES (142, '监考获取monitorKey', '/api/admin/monitor/getMonitorKey', 'LINK', 60, 28, NULL, '2020-08-01 12:08:31');
 COMMIT;
 
 -- ----------------------------
@@ -683,6 +684,20 @@ INSERT INTO `t_b_role_privilege` VALUES (141, 'INVIGILATE', 108);
 INSERT INTO `t_b_role_privilege` VALUES (142, 'INVIGILATE', 139);
 INSERT INTO `t_b_role_privilege` VALUES (143, 'INVIGILATE', 140);
 INSERT INTO `t_b_role_privilege` VALUES (144, 'ADMIN', 141);
+INSERT INTO `t_b_role_privilege` VALUES (145, 'INVIGILATE', 15);
+INSERT INTO `t_b_role_privilege` VALUES (146, 'INVIGILATE', 16);
+INSERT INTO `t_b_role_privilege` VALUES (147, 'INVIGILATE', 17);
+INSERT INTO `t_b_role_privilege` VALUES (148, 'INVIGILATE', 18);
+INSERT INTO `t_b_role_privilege` VALUES (149, 'INVIGILATE', 19);
+INSERT INTO `t_b_role_privilege` VALUES (150, 'ADMIN', 16);
+INSERT INTO `t_b_role_privilege` VALUES (151, 'ADMIN', 17);
+INSERT INTO `t_b_role_privilege` VALUES (152, 'ADMIN', 18);
+INSERT INTO `t_b_role_privilege` VALUES (153, 'ADMIN', 19);
+INSERT INTO `t_b_role_privilege` VALUES (154, 'ADMIN', 21);
+INSERT INTO `t_b_role_privilege` VALUES (155, 'ADMIN', 22);
+INSERT INTO `t_b_role_privilege` VALUES (156, 'ADMIN', 24);
+INSERT INTO `t_b_role_privilege` VALUES (157, 'ADMIN', 25);
+INSERT INTO `t_b_role_privilege` VALUES (158, 'INVIGILATE', 142);
 COMMIT;
 
 -- ----------------------------

+ 22 - 0
themis-business/src/main/resources/mapper/TEExamMapper.xml

@@ -170,4 +170,26 @@
 <!--            t.reallyTime = -1-->
 <!--            or t.reallyTime = 0-->
 <!--    </select>-->
+
+    <select id="examPrivilegeQuery" resultType="com.qmth.themis.business.entity.TEExam">
+        select
+            *
+        from
+            t_e_exam tee
+        where
+            EXISTS(
+            select
+                DISTINCT tees.exam_id
+            from
+                t_b_exam_invigilate_user tbeiu
+            left join t_e_exam_student tees on
+                tees.room_code = tbeiu.room_code
+            <where> 1 = 1
+                <if test="userId != null and userId != ''">
+                    and tbeiu.user_id = #{userId}
+                </if>
+                and tee.id = tees.exam_id
+            </where>
+                )
+        </select>
 </mapper>