Browse Source

Merge branch 'lingshan_master' of http://git.elinkit.com.cn:7070/r/epmet-cloud into lingshan_master

master
wxz 2 years ago
parent
commit
de46e965df
  1. 5
      epmet-commons/epmet-commons-tools/pom.xml
  2. 49
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/net/TCCCClientUtils.java
  3. 24
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/tccc/TCCCAuthController.java

5
epmet-commons/epmet-commons-tools/pom.xml

@ -197,6 +197,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java</artifactId>
<version>3.1.322</version>
</dependency>
</dependencies>
<build>

49
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/net/TCCCClientUtils.java

@ -0,0 +1,49 @@
package com.epmet.commons.tools.utils.net;
import com.tencentcloudapi.ccc.v20200210.CccClient;
import com.tencentcloudapi.ccc.v20200210.models.CreateSDKLoginTokenRequest;
import com.tencentcloudapi.ccc.v20200210.models.CreateSDKLoginTokenResponse;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class TCCCClientUtils {
private static String SDKAPPID = "1400801042";
private static String USERID = "286388969@qq.com";
private static String SECRETID = "AKIDynW4oQr6ED0a2dIn6EC3wgFlDVjrqIbg";
private static String SECRETKEY = "ymRuDJI8mCRUUPFvQqCPQME0c2MbfaM2";
public static String getToken() {
try {
Credential cred = new Credential(SECRETID, SECRETKEY);
// 实例化一个http选项,可选的,没有特殊需求可以跳过
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("ccc.ap-shanghai.tencentcloudapi.com");
// 实例化一个client选项,可选的,没有特殊需求可以跳过
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
// 实例化要请求产品的client对象,clientProfile是可选的
CccClient client = new CccClient(cred, "", clientProfile);
// 实例化一个请求对象,每个接口都会对应一个request对象
CreateSDKLoginTokenRequest req = new CreateSDKLoginTokenRequest();
req.setSdkAppId(1400801042L);
req.setSeatUserId("286388969@qq.com");
// 返回的resp是一个CreateSDKLoginTokenResponse的实例,与请求对象对应
CreateSDKLoginTokenResponse resp = client.CreateSDKLoginToken(req);
// 输出json格式的字符串回包
System.out.println(CreateSDKLoginTokenResponse.toJsonString(resp));
return CreateSDKLoginTokenResponse.toJsonString(resp);
} catch (TencentCloudSDKException e) {
log.error(e.toString());
return e.toString();
}
}
}

24
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/tccc/TCCCAuthController.java

@ -0,0 +1,24 @@
package com.epmet.controller.tccc;
import com.epmet.commons.tools.utils.net.TCCCClientUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("tccc")
public class TCCCAuthController {
@RequestMapping("getTcccAuth")
public String getTcccAuth() {
try {
String tcccAuth = TCCCClientUtils.getToken();
System.out.println(tcccAuth);
return tcccAuth;
} catch (Exception e) {
log.error(e.toString());
return e.toString();
}
}
}
Loading…
Cancel
Save