update===>:修改生成房间号方法及推送房间号。
This commit is contained in:
parent
2ebe1e1ece
commit
4e0844558d
@ -1,6 +1,7 @@
|
||||
package com.xinelu.applet.controller.videoconsultation;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.xinelu.applet.dto.consultationInfo.ConsultationInfoDTO;
|
||||
import com.xinelu.applet.service.consultationInfo.IConsultationInfoService;
|
||||
import com.xinelu.common.core.domain.R;
|
||||
import com.xinelu.common.core.dto.MessageTemplate;
|
||||
import com.xinelu.common.enums.MessageContentType;
|
||||
@ -16,6 +17,8 @@ import com.xinelu.common.utils.tencentcloudapi.trtc.v20190722.models.DissolveRoo
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@ -41,6 +44,10 @@ public class VideoConsultationController {
|
||||
private final static String ENDPOINT = "trtc.tencentcloudapi.com";
|
||||
private final static String REGION = "ap-beijing";
|
||||
|
||||
|
||||
@Resource
|
||||
private IConsultationInfoService consultationInfoService;
|
||||
|
||||
@ApiOperation("获取userSig")
|
||||
@GetMapping("getUserSig/{userId}")
|
||||
public R<String> getUserSig(@PathVariable String userId) {
|
||||
@ -49,19 +56,31 @@ public class VideoConsultationController {
|
||||
return R.ok(userSig);
|
||||
}
|
||||
|
||||
@ApiOperation("开始会诊")
|
||||
@GetMapping("start/{applyId}")
|
||||
public R<String> start(@PathVariable String applyId) {
|
||||
int roomId = RandomUtil.randomInt(1, 1000);
|
||||
@ApiOperation("开始视频")
|
||||
@GetMapping("start/{consultationInfoId}")
|
||||
public R<String> start(@PathVariable Long consultationInfoId) {
|
||||
// 房间号
|
||||
Random random = new Random();
|
||||
int randomNumber = random.nextInt(900000) + 100000; // 限制范围为 100000-999999
|
||||
String roomId = String.valueOf(randomNumber);
|
||||
if (roomId.length() < 6) {
|
||||
roomId = "0" + roomId; // 补零
|
||||
}
|
||||
MessageTemplate msg = new MessageTemplate();
|
||||
msg.setMessage(String.valueOf(roomId));
|
||||
msg.setToKey(applyId);
|
||||
// 根据图文咨询申请主键查询居民主键
|
||||
ConsultationInfoDTO consultationInfoDTO = consultationInfoService.selectConsultationInfoById(consultationInfoId);
|
||||
if (consultationInfoDTO == null) {
|
||||
return R.fail("生成房间号失败");
|
||||
}
|
||||
msg.setMessage(roomId);
|
||||
msg.setToKey(String.valueOf(consultationInfoDTO.getPatientId()));
|
||||
msg.setMsgType(MessageContentType.CONSULTATION.name());
|
||||
msg.setSendTime(new Date());
|
||||
WebSocketUtils.sendMessage(applyId, msg);
|
||||
return R.ok(String.valueOf(roomId));
|
||||
WebSocketUtils.sendMessage(String.valueOf(consultationInfoDTO.getPatientId()), msg);
|
||||
return R.ok(roomId);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("解散房间")
|
||||
@GetMapping("dissolveRoom/{roomId}")
|
||||
public R<?> dissolveRoom(@PathVariable String roomId) throws TencentCloudSDKException {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user