|
@@ -35,17 +35,9 @@ public class TencentYunServiceImpl extends ServiceImpl<ITencentYunMapper, Tencen
|
|
|
RedisUtil redisUtil;
|
|
|
|
|
|
@Override
|
|
|
- public JSONObject getSign(String userId) {
|
|
|
+ public JSONObject getSign(String userId,TencentYun tencentYun) {
|
|
|
String redisKey = RedisKeyUtil.TENCENT_YUN_KEY + userId;
|
|
|
if (!redisUtil.hasKey(redisKey)) {
|
|
|
- List<TencentYun> list = this.getByType(0);
|
|
|
- if(list == null || list.size() <=0){
|
|
|
- throw new BusinessException(ResultCode.TENCENT_YUN_EMPTY);
|
|
|
- }
|
|
|
- if(list.size() >1){
|
|
|
- throw new BusinessException(ResultCode.TENCENT_YUN_ERROR);
|
|
|
- }
|
|
|
- TencentYun tencentYun = list.get(0);
|
|
|
|
|
|
TLSSigAPIv2 api = new TLSSigAPIv2(tencentYun.getSdkAppid(), tencentYun.getSecretkey());
|
|
|
String sign = api.genUserSig(userId, tencentYun.getExTime() );
|
|
@@ -78,31 +70,23 @@ public class TencentYunServiceImpl extends ServiceImpl<ITencentYunMapper, Tencen
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Object getAgoraToken(String userId,Integer roleId,String channelName) {
|
|
|
+ public Object getAgoraToken(String userId,Integer roleId,String channelName,TencentYun tencentYun) {
|
|
|
if(roleMap.size() <=0){
|
|
|
setRoleMap();
|
|
|
}
|
|
|
if(roleMap.get(roleId) == null){
|
|
|
throw new BusinessException(ResultCode.AGO_ROLE_ERROR);
|
|
|
}
|
|
|
- List<TencentYun> list = this.getByType(1);
|
|
|
- if(list == null || list.size() <=0){
|
|
|
- throw new BusinessException(ResultCode.TENCENT_YUN_EMPTY);
|
|
|
- }
|
|
|
- if(list.size() >1){
|
|
|
- throw new BusinessException(ResultCode.TENCENT_YUN_ERROR);
|
|
|
- }
|
|
|
- TencentYun tencentYun = list.get(0);
|
|
|
-
|
|
|
- RtcTokenBuilder2 token = new RtcTokenBuilder2();
|
|
|
- String result = token.buildTokenWithUserAccount(tencentYun.getAppid(), tencentYun.getSecretkey(), channelName, userId, roleMap.get(roleId), tencentYun.getExTime(), tencentYun.getExTime());
|
|
|
+ RtcTokenBuilder2 token = new RtcTokenBuilder2();
|
|
|
+ String result = token.buildTokenWithUserAccount(tencentYun.getAppid(), tencentYun.getSecretkey(), channelName, userId, roleMap.get(roleId), tencentYun.getExTime(), tencentYun.getExTime());
|
|
|
+
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("sdkAppId",tencentYun.getAppid());
|
|
|
+ jsonObject.put("expire",tencentYun.getExTime());
|
|
|
+ jsonObject.put("sign",result);
|
|
|
+ jsonObject.put("operatorType",tencentYun.getOperatorType());
|
|
|
+ return jsonObject;
|
|
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("sdkAppId",tencentYun.getAppid());
|
|
|
- jsonObject.put("expire",tencentYun.getExTime());
|
|
|
- jsonObject.put("sign",result);
|
|
|
- jsonObject.put("operatorType",tencentYun.getOperatorType());
|
|
|
- return jsonObject;
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|