增加添加和绑定sn,增加阿里云推送

This commit is contained in:
hc
2025-08-10 20:13:45 +08:00
parent 301b23e6e6
commit 6eed13b07d
13 changed files with 721 additions and 44 deletions

View File

@@ -0,0 +1,49 @@
package com.onekeycall.videotablet.controller;
import com.onekeycall.videotablet.entity.DeviceInfo;
import com.onekeycall.videotablet.result.Result;
import com.onekeycall.videotablet.service.DeviceSnService;
import com.onekeycall.videotablet.service.UserService;
import com.onekeycall.videotablet.tencent.trtc.TLSSigAPIv2;
import com.onekeycall.videotablet.utils.JwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("/public")
public class TencentTrtcController {
@Autowired
private JwtUtil jwtUtil;
@Autowired
private UserService userService;
@Autowired
private DeviceSnService deviceSnService;
@GetMapping("/get_trtc_sig")
public Result getTrtcSig(
@RequestHeader("Authorization") String authHeader, @RequestHeader("Device-ID") String deviceId,
@RequestParam(value = "user_id") String userId
) {
if (!authHeader.startsWith("Bearer ")) {
return Result.error().message("Invalid Authorization header");
}
String token = authHeader.substring(7); // 去掉 "Bearer " 前缀
if (!jwtUtil.validateAccessToken(userId, token, deviceId)) {
return Result.error().message("Invalid token");
}
TLSSigAPIv2 tlsSigAPIv2 = new TLSSigAPIv2(1600100994, "ccc0d591fe50bd9c05df7e3182256eb43fd83d1127ae7dc01a3d256dd80f3ae2");
String sig = tlsSigAPIv2.genUserSig(userId);
Map<String, Object> map = new HashMap<>();
map.put("sig", sig);
map.put("expire", Instant.now().getEpochSecond() + TLSSigAPIv2.EXPIRETIME);
return Result.ok().data(map);
}
}