|
@@ -5,6 +5,7 @@ import com.qmth.themis.business.annotation.ApiJsonObject;
|
|
|
import com.qmth.themis.business.annotation.ApiJsonProperty;
|
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
|
import com.qmth.themis.business.entity.TIeExamInvigilateCall;
|
|
|
+import com.qmth.themis.business.enums.FieldUniqueEnum;
|
|
|
import com.qmth.themis.business.service.TIeExamInvigilateCallService;
|
|
|
import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
@@ -13,11 +14,9 @@ import com.qmth.themis.common.util.ResultUtil;
|
|
|
import io.swagger.annotations.*;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.HashMap;
|
|
@@ -53,17 +52,31 @@ public class TIeInvigilateCallController {
|
|
|
if (Objects.isNull(mapParameter.get("recordId")) || Objects.equals(mapParameter.get("recordId"), "")) {
|
|
|
throw new BusinessException(ExceptionResultEnum.RECORD_ID_IS_NULL);
|
|
|
}
|
|
|
- Long recordId = Long.parseLong(String.valueOf(mapParameter.get("recordId")));
|
|
|
- if (Objects.isNull(mapParameter.get("source")) || Objects.equals(mapParameter.get("source"), "")) {
|
|
|
- throw new BusinessException("监考视频源不能为空");
|
|
|
- }
|
|
|
- String source = String.valueOf(mapParameter.get("source"));
|
|
|
- if (Objects.isNull(mapParameter.get("liveUrl")) || Objects.equals(mapParameter.get("liveUrl"), "")) {
|
|
|
- throw new BusinessException("观看地址不能为空");
|
|
|
+ Long recordId = null;
|
|
|
+ try {
|
|
|
+ recordId = Long.parseLong(String.valueOf(mapParameter.get("recordId")));
|
|
|
+ if (Objects.isNull(mapParameter.get("source")) || Objects.equals(mapParameter.get("source"), "")) {
|
|
|
+ throw new BusinessException("监考视频源不能为空");
|
|
|
+ }
|
|
|
+ String source = String.valueOf(mapParameter.get("source"));
|
|
|
+ if (Objects.isNull(mapParameter.get("liveUrl")) || Objects.equals(mapParameter.get("liveUrl"), "")) {
|
|
|
+ throw new BusinessException("观看地址不能为空");
|
|
|
+ }
|
|
|
+ String liveUrl = String.valueOf(mapParameter.get("liveUrl"));
|
|
|
+ TIeExamInvigilateCall tIeExamInvigilateCall = new TIeExamInvigilateCall(recordId, source, liveUrl);
|
|
|
+ tIeExamInvigilateCallService.save(tIeExamInvigilateCall);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ if (e instanceof DuplicateKeyException) {
|
|
|
+ String errorColumn = e.getCause().toString();
|
|
|
+ String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
|
|
|
+ throw new BusinessException("考试记录id[" + recordId + "]下的" + FieldUniqueEnum.convertToCode(columnStr) + "数据不允许重复插入");
|
|
|
+ } else if (e instanceof BusinessException) {
|
|
|
+ throw new BusinessException(e.getMessage());
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
}
|
|
|
- String liveUrl = String.valueOf(mapParameter.get("liveUrl"));
|
|
|
- TIeExamInvigilateCall tIeExamInvigilateCall = new TIeExamInvigilateCall(recordId, source, liveUrl);
|
|
|
- tIeExamInvigilateCallService.save(tIeExamInvigilateCall);
|
|
|
return ResultUtil.ok(SystemConstant.SUCCESS);
|
|
|
}
|
|
|
|
|
@@ -122,4 +135,16 @@ public class TIeInvigilateCallController {
|
|
|
map.put(SystemConstant.RECORDS, tIeExamInvigilateCallList);
|
|
|
return ResultUtil.ok(map);
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "监考监控通话查询来源接口")
|
|
|
+ @RequestMapping(value = "/call/query", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "监考监控信息", response = TIeExamInvigilateCall.class)})
|
|
|
+ public Result callQuery(@ApiParam(value = "考试记录id", required = true) @RequestParam(required = true) Long recordId) {
|
|
|
+ QueryWrapper<TIeExamInvigilateCall> tIeExamInvigilateCallQueryWrapper = new QueryWrapper<>();
|
|
|
+ tIeExamInvigilateCallQueryWrapper.lambda().eq(TIeExamInvigilateCall::getExamRecordId, recordId);
|
|
|
+ List<TIeExamInvigilateCall> tIeExamInvigilateCallList = tIeExamInvigilateCallService.list(tIeExamInvigilateCallQueryWrapper);
|
|
|
+ Map map = new HashMap<>();
|
|
|
+ map.put(SystemConstant.RECORDS, tIeExamInvigilateCallList);
|
|
|
+ return ResultUtil.ok(map);
|
|
|
+ }
|
|
|
}
|