Commit c5e9c399 by huangjy

feat:设备列表呼叫设备

parent e22e676e
...@@ -108,6 +108,12 @@ public class PlatDeviceController { ...@@ -108,6 +108,12 @@ public class PlatDeviceController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@ApiOperation("设备呼叫设备")
@PostMapping("callingDevice")
public ApiResponseEntity<PlatAlarmCallDeviceVO> callingDevice(@RequestBody PlatCallingDeviceDTO dto) {
return ApiResponseUtils.success(platDeviceService.callingDevice(dto));
}
@ApiOperation("设备获取登录RTMtoken") @ApiOperation("设备获取登录RTMtoken")
@PostMapping("getDeviceRtmToken") @PostMapping("getDeviceRtmToken")
......
...@@ -86,4 +86,6 @@ public interface PlatDeviceService extends IService<PlatDevice> { ...@@ -86,4 +86,6 @@ public interface PlatDeviceService extends IService<PlatDevice> {
void active(BaseIdDTO dto); void active(BaseIdDTO dto);
PlatAlarmCallDeviceVO getDeviceRtmToken(PlatCallingDeviceDTO dto); PlatAlarmCallDeviceVO getDeviceRtmToken(PlatCallingDeviceDTO dto);
PlatAlarmCallDeviceVO callingDevice(PlatCallingDeviceDTO dto);
} }
...@@ -55,6 +55,7 @@ import com.makeit.service.platform.space.PlatSpaceService; ...@@ -55,6 +55,7 @@ import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.service.saas.PlatTenantService; import com.makeit.service.saas.PlatTenantService;
import com.makeit.shengwang.agora.dto.PlatCallingDeviceDTO; import com.makeit.shengwang.agora.dto.PlatCallingDeviceDTO;
import com.makeit.shengwang.agora.http.ShengwangHttpUtil; import com.makeit.shengwang.agora.http.ShengwangHttpUtil;
import com.makeit.shengwang.agora.media.RtcTokenBuilder2;
import com.makeit.shengwang.agora.service.ShengwangService; import com.makeit.shengwang.agora.service.ShengwangService;
import com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO; import com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO;
import com.makeit.utils.DeviceCacheUtil; import com.makeit.utils.DeviceCacheUtil;
...@@ -79,6 +80,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -79,6 +80,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneOffset; import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
...@@ -767,6 +769,23 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -767,6 +769,23 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
} }
@Override @Override
public PlatAlarmCallDeviceVO callingDevice(PlatCallingDeviceDTO dto) {
PlatAlarmCallDeviceVO platAlarmCallDeviceVO = new PlatAlarmCallDeviceVO();
PlatDevice platDevice = getById(dto.getId());
platAlarmCallDeviceVO.setDeviceId(platDevice.getOriDeviceId());
platAlarmCallDeviceVO.setAppId(shengwangProperties.getAppId());
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
String channelName = String.format("%s:%s","RTC",now.format(dateTimeFormatter));
RtcTokenBuilder2 token = new RtcTokenBuilder2();
String result = token.buildTokenWithUid(shengwangProperties.getAppId(), shengwangProperties.getAppCertificate(), channelName, 0, RtcTokenBuilder2.Role.ROLE_SUBSCRIBER,
shengwangProperties.getTokenExpirationInSeconds(), shengwangProperties.getPrivilegeExpirationInSeconds());
platAlarmCallDeviceVO.setAccessToken(result);
platAlarmCallDeviceVO.setChannelName(channelName);
return platAlarmCallDeviceVO;
}
@Override
public PlatAlarmCallDeviceVO getDeviceRtmToken(PlatCallingDeviceDTO dto) { public PlatAlarmCallDeviceVO getDeviceRtmToken(PlatCallingDeviceDTO dto) {
return shengwangService.callingDeviceAuthIgnoreRtm(dto); return shengwangService.callingDeviceAuthIgnoreRtm(dto);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment