|
|
@@ -0,0 +1,51 @@
|
|
|
+package com.zhongzheng.modules.face.service.impl;
|
|
|
+
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.tencentcloudapi.common.Credential;
|
|
|
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
|
|
+import com.tencentcloudapi.common.profile.ClientProfile;
|
|
|
+import com.tencentcloudapi.common.profile.HttpProfile;
|
|
|
+import com.tencentcloudapi.faceid.v20180301.FaceidClient;
|
|
|
+import com.tencentcloudapi.faceid.v20180301.models.DetectAuthRequest;
|
|
|
+import com.tencentcloudapi.faceid.v20180301.models.DetectAuthResponse;
|
|
|
+import com.zhongzheng.modules.exam.domain.ExamArrangementGuide;
|
|
|
+import com.zhongzheng.modules.face.bo.FaceVo;
|
|
|
+import com.zhongzheng.modules.face.service.IFaceService;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class FaceServiceImpl implements IFaceService {
|
|
|
+
|
|
|
+ @Value("${tencent.cloud.SecretId}")
|
|
|
+ private String SecretId;
|
|
|
+
|
|
|
+ @Value("${tencent.cloud.SecretKey}")
|
|
|
+ private String SecretKey;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public FaceVo getFaceDetectAuth() {
|
|
|
+ try{
|
|
|
+ Credential cred = new Credential(SecretId, SecretKey);
|
|
|
+
|
|
|
+ HttpProfile httpProfile = new HttpProfile();
|
|
|
+ httpProfile.setEndpoint("faceid.tencentcloudapi.com");
|
|
|
+ ClientProfile clientProfile = new ClientProfile();
|
|
|
+ clientProfile.setHttpProfile(httpProfile);
|
|
|
+ FaceidClient client = new FaceidClient(cred, "", clientProfile);
|
|
|
+ String params = "{\"RuleId\":\"0\"}";
|
|
|
+ DetectAuthRequest req = DetectAuthRequest.fromJsonString(params, DetectAuthRequest.class);
|
|
|
+ // DetectAuthRequest req = new DetectAuthRequest();
|
|
|
+ DetectAuthResponse resp = client.DetectAuth(req);
|
|
|
+ System.out.println(DetectAuthResponse.toJsonString(resp));
|
|
|
+ FaceVo vo = BeanUtil.toBean(resp, com.zhongzheng.modules.face.bo.FaceVo.class);
|
|
|
+ return vo;
|
|
|
+ // return resp.getBizToken();
|
|
|
+ } catch (TencentCloudSDKException e) {
|
|
|
+ System.out.println(e.toString());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|