Sfoglia il codice sorgente

Merge branch 'feature-2022.07.29' of https://git.flowbb.cn/RK-Dev/fqgz-server into feature-2022.07.29

humuyu 3 anni fa
parent
commit
8ff91c3683

+ 3 - 8
eladmin-system/src/main/java/me/zhengjie/application/admin/controller/AdminOrderController.java

@@ -5,17 +5,12 @@ import com.alibaba.fastjson.JSONObject;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import me.zhengjie.annotation.rest.AnonymousPostMapping;
-import me.zhengjie.application.admin.controller.vo.AdminOrderVO;
-import me.zhengjie.application.admin.controller.vo.NotaryOrderQueryReq;
-import me.zhengjie.application.admin.controller.vo.NotaryOrderQueryRsp;
-import me.zhengjie.application.admin.controller.vo.PartyEntity;
+import me.zhengjie.application.admin.controller.vo.*;
 import me.zhengjie.application.admin.service.AdminOrderService;
-import me.zhengjie.application.admin.controller.vo.FileVo;
-import me.zhengjie.application.admin.controller.vo.OrderDetailDto;
 import me.zhengjie.base.AppBaseResponse;
 import me.zhengjie.base.AppResultData;
 import me.zhengjie.base.ResultCode;
-import me.zhengjie.base.util.TencentUtil;
+import me.zhengjie.base.util.TencentServiceUtil;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -174,7 +169,7 @@ public class AdminOrderController {
 			return response;
 		}
 		String imageBase64 = Base64.getEncoder().encodeToString(fileByte);
-		String result = TencentUtil.FaceImageBody(idCard, name, imageBase64);
+		String result = TencentServiceUtil.FaceImageBody(idCard, name, imageBase64);
 		JSONObject object = JSON.parseObject(result);
 		Float sim = Float.parseFloat(object.getString("Sim"));
 		log.info("认证入参:" + idCard + "/" + name);

+ 12 - 17
eladmin-system/src/main/java/me/zhengjie/application/user/service/impl/SmsServiceImpl.java

@@ -1,27 +1,22 @@
 package me.zhengjie.application.user.service.impl;
 
-import java.util.Date;
-
-import java.util.Random;
-
+import com.google.gson.JsonObject;
 import lombok.RequiredArgsConstructor;
+import me.zhengjie.application.bank.service.BankOrderService;
+import me.zhengjie.application.user.service.SmsService;
+import me.zhengjie.application.user.vo.SmsLog;
 import me.zhengjie.application.user.vo.SmsVo;
+import me.zhengjie.base.ResponseDTO;
+import me.zhengjie.base.ResultCode;
+import me.zhengjie.base.util.DateUtils;
+import me.zhengjie.base.util.TencentServiceUtil;
+import me.zhengjie.domain.sms.CommonConstants;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import com.google.gson.JsonObject;
-
-import me.zhengjie.domain.sms.CommonConstants;
-
-import me.zhengjie.application.user.vo.SmsLog;
-import me.zhengjie.application.bank.service.BankOrderService;
-import me.zhengjie.application.user.service.SmsService;
-import me.zhengjie.base.util.DateUtils;
-
-import me.zhengjie.base.util.TencentSendSms;
-import me.zhengjie.base.ResponseDTO;
-import me.zhengjie.base.ResultCode;
+import java.util.Date;
+import java.util.Random;
 
 @Service
 @RequiredArgsConstructor
@@ -72,7 +67,7 @@ public class SmsServiceImpl implements SmsService {
 			return ResponseDTO.error(ResultCode.MSG_SEND_FREQUENT);
 		}
 
-		String returnContent = TencentSendSms.sendMsg(phone, code, String.valueOf(time));
+		String returnContent = TencentServiceUtil.sendMsg(phone, code, String.valueOf(time));
 		// String returnContent =
 		// "{\"SendStatusSet\":[{\"SerialNo\":\"2433:356830619416427570703644735\",\"PhoneNumber\":\"+8613813947352\",\"Fee\":1,\"SessionContext\":\"xxx\",\"Code\":\"Ok\",\"Message\":\"send
 		// success\",\"IsoCode\":\"CN\"}],\"RequestId\":\"b760dfe4-2f21-4be2-a5ed-53c7e06105ca\"}";

+ 0 - 82
eladmin-system/src/main/java/me/zhengjie/base/config/ProcessMedia.java

@@ -1,82 +0,0 @@
-package me.zhengjie.base.config;
-
-import com.tencentcloudapi.common.Credential;
-import com.tencentcloudapi.common.profile.ClientProfile;
-import com.tencentcloudapi.common.profile.HttpProfile;
-import com.tencentcloudapi.common.exception.TencentCloudSDKException;
-import com.tencentcloudapi.vod.v20180717.VodClient;
-import com.tencentcloudapi.vod.v20180717.models.*;
-
-public class ProcessMedia {
-	public static void main(String[] args) {
-		 show();
-		 video();
-	}
-
-	public static void show() {
-
-		try {
-			// 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
-			// 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
-			Credential cred = new Credential("AKIDCD2b091cvxiDRP6VeX9VaOvBAsKVQ4SZ",
-					"qPhjUyA5j6C1ZqqZ2D7k8bniLhma7NQH");
-			// 实例化一个http选项,可选的,没有特殊需求可以跳过
-			HttpProfile httpProfile = new HttpProfile();
-			httpProfile.setEndpoint("vod.tencentcloudapi.com");
-			// 实例化一个client选项,可选的,没有特殊需求可以跳过
-			ClientProfile clientProfile = new ClientProfile();
-			clientProfile.setHttpProfile(httpProfile);
-			// 实例化要请求产品的client对象,clientProfile是可选的
-			VodClient client = new VodClient(cred, "", clientProfile);
-			// 实例化一个请求对象,每个接口都会对应一个request对象
-			ProcessMediaRequest req = new ProcessMediaRequest();
-			req.setFileId("387702299191635251");
-			MediaProcessTaskInput mediaProcessTaskInput1 = new MediaProcessTaskInput();
-
-			TranscodeTaskInput[] transcodeTaskInputs1 = new TranscodeTaskInput[1];
-			TranscodeTaskInput transcodeTaskInput1 = new TranscodeTaskInput();
-			transcodeTaskInput1.setDefinition(20L);
-			transcodeTaskInputs1[0] = transcodeTaskInput1;
-
-			mediaProcessTaskInput1.setTranscodeTaskSet(transcodeTaskInputs1);
-
-			req.setMediaProcessTask(mediaProcessTaskInput1);
-
-			// 返回的resp是一个ProcessMediaResponse的实例,与请求对象对应
-			ProcessMediaResponse resp = client.ProcessMedia(req);
-			// 输出json格式的字符串回包
-			System.out.println(ProcessMediaResponse.toJsonString(resp));
-		} catch (TencentCloudSDKException e) {
-			System.out.println(e.toString());
-		}
-
-	}
-
-	public static void video() {
-		try {
-			// 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
-			// 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
-			Credential cred = new Credential("AKIDCD2b091cvxiDRP6VeX9VaOvBAsKVQ4SZ",
-					"qPhjUyA5j6C1ZqqZ2D7k8bniLhma7NQH");
-			// 实例化一个http选项,可选的,没有特殊需求可以跳过
-			HttpProfile httpProfile = new HttpProfile();
-			httpProfile.setEndpoint("vod.tencentcloudapi.com");
-			// 实例化一个client选项,可选的,没有特殊需求可以跳过
-			ClientProfile clientProfile = new ClientProfile();
-			clientProfile.setHttpProfile(httpProfile);
-			// 实例化要请求产品的client对象,clientProfile是可选的
-			VodClient client = new VodClient(cred, "", clientProfile);
-			// 实例化一个请求对象,每个接口都会对应一个request对象
-			DescribeMediaInfosRequest req = new DescribeMediaInfosRequest();
-			String[] fileIds1 = { "387702299191635251" };
-			req.setFileIds(fileIds1);
-
-			// 返回的resp是一个DescribeMediaInfosResponse的实例,与请求对象对应
-			DescribeMediaInfosResponse resp = client.DescribeMediaInfos(req);
-			// 输出json格式的字符串回包
-			System.out.println(DescribeMediaInfosResponse.toJsonString(resp));
-		} catch (TencentCloudSDKException e) {
-			System.out.println(e.toString());
-		}
-	}
-}

+ 0 - 99
eladmin-system/src/main/java/me/zhengjie/base/util/PullSmsSendStatus.java

@@ -1,99 +0,0 @@
-package me.zhengjie.base.util;
-
-import com.tencentcloudapi.common.Credential;
-import com.tencentcloudapi.common.exception.TencentCloudSDKException;
-
-//导入可选配置类
-import com.tencentcloudapi.common.profile.ClientProfile;
-import com.tencentcloudapi.common.profile.HttpProfile;
-
-// 导入对应SMS模块的client
-import com.tencentcloudapi.sms.v20210111.SmsClient;
-
-// 导入要请求接口对应的request response类
-
-import com.tencentcloudapi.sms.v20210111.models.PullSmsSendStatusRequest;
-import com.tencentcloudapi.sms.v20210111.models.PullSmsSendStatusResponse;;
-
-/**
- * Tencent Cloud Sms PullSmsSendStatus
- *
- */
-public class PullSmsSendStatus {
-	public static void main(String[] args) {
-		try {
-			/*
-			 * 必要步骤: 实例化一个认证对象,入参需要传入腾讯云账户密钥对secretId,secretKey。
-			 * 这里采用的是从环境变量读取的方式,需要在环境变量中先设置这两个值。 你也可以直接在代码中写死密钥对,但是小心不要将代码复制、上传或者分享给他人,
-			 * 以免泄露密钥对危及你的财产安全。 CAM密匙查询: https://console.cloud.tencent.com/cam/capi
-			 */
-			Credential cred = new Credential("secretId", "secretKey");
-
-			// 实例化一个http选项,可选,没有特殊需求可以跳过
-			HttpProfile httpProfile = new HttpProfile();
-			// 设置代理
-			// httpProfile.setProxyHost("真实代理ip");
-			// httpProfile.setProxyPort(真实代理端口);
-			/*
-			 * SDK默认使用POST方法。 如果你一定要使用GET方法,可以在这里设置。GET方法无法处理一些较大的请求
-			 */
-			httpProfile.setReqMethod("POST");
-			/*
-			 * SDK有默认的超时时间,非必要请不要进行调整 如有需要请在代码中查阅以获取最新的默认值
-			 */
-			httpProfile.setConnTimeout(60);
-			/*
-			 * SDK会自动指定域名。通常是不需要特地指定域名的,但是如果你访问的是金融区的服务 则必须手动指定域名,例如sms的上海金融区域名:
-			 * sms.ap-shanghai-fsi.tencentcloudapi.com
-			 */
-			httpProfile.setEndpoint("sms.tencentcloudapi.com");
-
-			/*
-			 * 非必要步骤: 实例化一个客户端配置对象,可以指定超时时间等配置
-			 */
-			ClientProfile clientProfile = new ClientProfile();
-			/*
-			 * SDK默认用TC3-HMAC-SHA256进行签名 非必要请不要修改这个字段
-			 */
-			clientProfile.setSignMethod("HmacSHA256");
-			clientProfile.setHttpProfile(httpProfile);
-
-			/*
-			 * 实例化要请求产品(以sms为例)的client对象 第二个参数是地域信息,可以直接填写字符串ap-guangzhou,或者引用预设的常量
-			 */
-			SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
-
-			/*
-			 * 实例化一个请求对象,根据调用的接口和实际情况,可以进一步设置请求参数 你可以直接查询SDK源码确定接口有哪些属性可以设置
-			 * 属性可能是基本类型,也可能引用了另一个数据结构 推荐使用IDE进行开发,可以方便的跳转查阅各个接口和数据结构的文档说明
-			 */
-			PullSmsSendStatusRequest req = new PullSmsSendStatusRequest();
-
-			/*
-			 * 填充请求参数,这里request对象的成员变量即对应接口的入参 你可以通过官网接口文档或跳转到request对象的定义处查看请求参数的定义
-			 * 基本类型的设置: 帮助链接: 短信控制台: https://console.cloud.tencent.com/smsv2 sms helper:
-			 * https://cloud.tencent.com/document/product/382/3773
-			 */
-
-			/* 短信应用ID: 短信SdkAppId在 [短信控制台] 添加应用后生成的实际SdkAppId,示例如1400006666 */
-			String sdkAppId = "1400009099";
-			req.setSmsSdkAppId(sdkAppId);
-
-			// 设置拉取最大条数,最多100条
-			Long limit = 5L;
-			req.setLimit(limit);
-
-			/*
-			 * 通过 client 对象调用 PullSmsSendStatus 方法发起请求。注意请求方法名与请求对象是对应的 返回的 res 是一个
-			 * PullSmsSendStatusResponse 类的实例,与请求对象对应
-			 */
-			PullSmsSendStatusResponse res = client.PullSmsSendStatus(req);
-
-			// 输出json格式的字符串回包
-			System.out.println(PullSmsSendStatusResponse.toJsonString(res));
-
-		} catch (TencentCloudSDKException e) {
-			e.printStackTrace();
-		}
-	}
-}

+ 0 - 132
eladmin-system/src/main/java/me/zhengjie/base/util/TencentSendSms.java

@@ -1,132 +0,0 @@
-package me.zhengjie.base.util;
-
-import com.tencentcloudapi.common.Credential;
-import com.tencentcloudapi.common.exception.TencentCloudSDKException;
-
-//导入可选配置类
-import com.tencentcloudapi.common.profile.ClientProfile;
-import com.tencentcloudapi.common.profile.HttpProfile;
-
-// 导入对应SMS模块的client
-import com.tencentcloudapi.sms.v20210111.SmsClient;
-
-// 导入要请求接口对应的request response类
-import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
-import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
-
-/**
- * Tencent Cloud Sms Sendsms
- *
- */
-public class TencentSendSms {
-
-	public static String sendMsg(String phone, String code, String time) {
-
-		try {
-			/*
-			 * 必要步骤: 实例化一个认证对象,入参需要传入腾讯云账户密钥对secretId,secretKey。
-			 * 这里采用的是从环境变量读取的方式,需要在环境变量中先设置这两个值。 你也可以直接在代码中写死密钥对,但是小心不要将代码复制、上传或者分享给他人,
-			 * 以免泄露密钥对危及你的财产安全。 CAM密匙查询: https://console.cloud.tencent.com/cam/capi
-			 */
-			Credential cred = new Credential("AKIDCD2b091cvxiDRP6VeX9VaOvBAsKVQ4SZ",
-					"qPhjUyA5j6C1ZqqZ2D7k8bniLhma7NQH");
-
-			// 实例化一个http选项,可选,没有特殊需求可以跳过
-			HttpProfile httpProfile = new HttpProfile();
-			// 设置代理
-			// httpProfile.setProxyHost("真实代理ip");
-			// httpProfile.setProxyPort(真实代理端口);
-			/*
-			 * SDK默认使用POST方法。 如果你一定要使用GET方法,可以在这里设置。GET方法无法处理一些较大的请求
-			 */
-			httpProfile.setReqMethod("POST");
-			/*
-			 * SDK有默认的超时时间,非必要请不要进行调整 如有需要请在代码中查阅以获取最新的默认值
-			 */
-			httpProfile.setConnTimeout(60);
-			/*
-			 * SDK会自动指定域名。通常是不需要特地指定域名的,但是如果你访问的是金融区的服务 则必须手动指定域名,例如sms的上海金融区域名:
-			 * sms.ap-shanghai-fsi.tencentcloudapi.com
-			 */
-			httpProfile.setEndpoint("sms.tencentcloudapi.com");
-
-			/*
-			 * 非必要步骤: 实例化一个客户端配置对象,可以指定超时时间等配置
-			 */
-			ClientProfile clientProfile = new ClientProfile();
-			/*
-			 * SDK默认用TC3-HMAC-SHA256进行签名 非必要请不要修改这个字段
-			 */
-			clientProfile.setSignMethod("HmacSHA256");
-			clientProfile.setHttpProfile(httpProfile);
-			/*
-			 * 实例化要请求产品(以sms为例)的client对象 第二个参数是地域信息,可以直接填写字符串ap-guangzhou,或者引用预设的常量
-			 */
-			SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
-			/*
-			 * 实例化一个请求对象,根据调用的接口和实际情况,可以进一步设置请求参数 你可以直接查询SDK源码确定接口有哪些属性可以设置
-			 * 属性可能是基本类型,也可能引用了另一个数据结构 推荐使用IDE进行开发,可以方便的跳转查阅各个接口和数据结构的文档说明
-			 */
-			SendSmsRequest req = new SendSmsRequest();
-
-			/*
-			 * 填充请求参数,这里request对象的成员变量即对应接口的入参 你可以通过官网接口文档或跳转到request对象的定义处查看请求参数的定义
-			 * 基本类型的设置: 帮助链接: 短信控制台: https://console.cloud.tencent.com/smsv2 sms helper:
-			 * https://cloud.tencent.com/document/product/382/3773
-			 */
-
-			/* 短信应用ID: 短信SdkAppId在 [短信控制台] 添加应用后生成的实际SdkAppId,示例如1400006666 */
-			String sdkAppId = "1400625259";
-			req.setSmsSdkAppId(sdkAppId);
-
-			/* 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名,签名信息可登录 [短信控制台] 查看 */
-			String signName = "苏州展翼天创数字科技有限";
-			req.setSignName(signName);
-
-			/* 国际/港澳台短信 SenderId: 国内短信填空,默认未开通,如需开通请联系 [sms helper] */
-			String senderid = "";
-			req.setSenderId(senderid);
-
-			/* 用户的 session 内容: 可以携带用户侧 ID 等上下文信息,server 会原样返回 */
-			String sessionContext = "xxx";
-			req.setSessionContext(sessionContext);
-
-			/* 短信号码扩展号: 默认未开通,如需开通请联系 [sms helper] */
-			String extendCode = "";
-			req.setExtendCode(extendCode);
-
-			/* 模板 ID: 必须填写已审核通过的模板 ID。模板ID可登录 [短信控制台] 查看 */
-			String templateId = "1281636";
-			req.setTemplateId(templateId);
-
-			/*
-			 * 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号] 示例如:+8613711112222, 其中前面有一个+号
-			 * ,86为国家码,13711112222为手机号,最多不要超过200个手机号
-			 */
-			String[] phoneNumberSet = { phone };
-			req.setPhoneNumberSet(phoneNumberSet);
-
-			/* 模板参数: 若无模板参数,则设置为空 */
-			String[] templateParamSet = { code, time };
-			req.setTemplateParamSet(templateParamSet);
-
-			/*
-			 * 通过 client 对象调用 SendSms 方法发起请求。注意请求方法名与请求对象是对应的 返回的 res 是一个 SendSmsResponse
-			 * 类的实例,与请求对象对应
-			 */
-			SendSmsResponse res = client.SendSms(req);
-			return SendSmsResponse.toJsonString(res);
-			// 输出json格式的字符串回包
-			// System.out.println();
-
-			// 也可以取出单个值,你可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
-			// System.out.println(res.getRequestId());
-
-		} catch (TencentCloudSDKException e) {
-			e.printStackTrace();
-			return null;
-		}
-
-	}
-
-}

+ 261 - 5
eladmin-system/src/main/java/me/zhengjie/base/util/TencentServiceUtil.java

@@ -1,14 +1,21 @@
 package me.zhengjie.base.util;
 
+import com.alibaba.fastjson.JSONObject;
 import com.tencentcloudapi.common.Credential;
 import com.tencentcloudapi.common.profile.ClientProfile;
 import com.tencentcloudapi.common.profile.HttpProfile;
 import com.tencentcloudapi.common.exception.TencentCloudSDKException;
 import com.tencentcloudapi.faceid.v20180301.FaceidClient;
-import com.tencentcloudapi.faceid.v20180301.models.IdCardVerificationRequest;
-import com.tencentcloudapi.faceid.v20180301.models.IdCardVerificationResponse;
+import com.tencentcloudapi.faceid.v20180301.models.*;
+import com.tencentcloudapi.iai.v20200303.IaiClient;
+import com.tencentcloudapi.iai.v20200303.models.CompareFaceRequest;
+import com.tencentcloudapi.iai.v20200303.models.CompareFaceResponse;
 import com.tencentcloudapi.ocr.v20181119.OcrClient;
 import com.tencentcloudapi.ocr.v20181119.models.*;
+import com.tencentcloudapi.sms.v20210111.SmsClient;
+import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
+import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
+import lombok.extern.slf4j.Slf4j;
 import me.zhengjie.base.config.AppConfigInfo;
 import org.springframework.web.multipart.MultipartFile;
 import sun.misc.BASE64Encoder;
@@ -22,11 +29,12 @@ import java.awt.image.BufferedImage;
 import java.io.*;
 import java.util.Iterator;
 
+@Slf4j
 public class TencentServiceUtil {
 
-    // 展翼天创
-    private static final String SECRET_ID = "AKIDCD2b091cvxiDRP6VeX9VaOvBAsKVQ4SZ";
-    private static final String SECRET_KEY = "qPhjUyA5j6C1ZqqZ2D7k8bniLhma7NQH";
+    // 软控配置
+    private static final String SECRET_ID = "AKIDO7duvhh3xb0C9G5i38xcGftrbBWvZCxY";
+    private static final String SECRET_KEY = "ZN7sVvAAzaw4Viz9AwSiiQtAD4g2B5tR";
 
     /**
      * 手写签名识别(已使用)
@@ -161,6 +169,254 @@ public class TencentServiceUtil {
     }
 
     /**
+     * 人脸比对(未使用)
+     *
+     * @param imageA
+     * @param urlB
+     * @return
+     */
+    public static String compareFace(String imageA, String urlB) {
+        try {
+
+            Credential cred = new Credential(SECRET_ID, SECRET_KEY);
+
+            HttpProfile httpProfile = new HttpProfile();
+            httpProfile.setEndpoint("iai.tencentcloudapi.com");
+
+            ClientProfile clientProfile = new ClientProfile();
+            clientProfile.setHttpProfile(httpProfile);
+
+            IaiClient client = new IaiClient(cred, "ap-shanghai", clientProfile);
+            JSONObject paramObj = new JSONObject();
+            paramObj.put("ImageA", imageA);
+            paramObj.put("UrlB", urlB);
+//            log.info("需验证图片: " + imageA);
+            log.info("业务底照地址: " + urlB);
+            CompareFaceRequest req = CompareFaceRequest.fromJsonString(paramObj.toJSONString(),
+                    CompareFaceRequest.class);
+            CompareFaceResponse resp = client.CompareFace(req);
+            String resultStr = CompareFaceResponse.toJsonString(resp);
+            log.info("人脸对比检测结果: " + resultStr);
+            return resultStr;
+        } catch (TencentCloudSDKException e) {
+            log.error("人脸对比发生错误,异常: " + e.getMessage());
+            return "";
+        }
+    }
+
+    /**
+     * 活体人脸核身(视频 + 姓名 + 证件号码)(未使用)
+     *
+     * @param idCard
+     * @param name
+     * @param videoBase64
+     */
+    public static String FaceNuclearBody(String idCard, String name, String videoBase64) {
+        JSONObject obj = new JSONObject();
+        obj.put("IdCard", idCard);
+        obj.put("Name", name);
+        obj.put("VideoBase64", videoBase64);
+        obj.put("LivenessType", "ACTION");
+        obj.put("ValidateData", "1,2");
+        try {
+            Credential cred = new Credential(SECRET_ID, SECRET_KEY);
+            HttpProfile httpProfile = new HttpProfile();
+            httpProfile.setEndpoint("faceid.tencentcloudapi.com");
+
+            ClientProfile clientProfile = new ClientProfile();
+            clientProfile.setHttpProfile(httpProfile);
+
+            FaceidClient client = new FaceidClient(cred, "ap-shanghai", clientProfile);
+
+            String params = obj.toJSONString();
+            LivenessRecognitionRequest req = LivenessRecognitionRequest.fromJsonString(params,
+                    LivenessRecognitionRequest.class);
+            LivenessRecognitionResponse resp = client.LivenessRecognition(req);
+            return LivenessRecognitionResponse.toJsonString(resp);
+            // return s;
+        } catch (TencentCloudSDKException e) {
+            log.error("活体人脸核身失败: " + e.getMessage());
+            return "";
+        }
+    }
+
+    /**
+     * 照片人脸核身(照片 + 姓名 + 证件号码)(已使用)
+     *
+     * @param idCard
+     * @param name
+     * @param ImageBase64
+     */
+    public static String FaceImageBody(String idCard, String name, String ImageBase64) {
+        try {
+            Credential cred = new Credential(SECRET_ID, SECRET_KEY);;
+            HttpProfile httpProfile = new HttpProfile();
+            httpProfile.setEndpoint("faceid.tencentcloudapi.com");
+
+            ClientProfile clientProfile = new ClientProfile();
+            clientProfile.setHttpProfile(httpProfile);
+
+            FaceidClient client = new FaceidClient(cred, "ap-shanghai", clientProfile);
+
+            ImageRecognitionRequest req = new ImageRecognitionRequest();
+            req.setIdCard(idCard);
+            req.setName(name);
+            req.setImageBase64(ImageBase64);
+            ImageRecognitionResponse resp = client.ImageRecognition(req);
+            return ImageRecognitionResponse.toJsonString(resp);
+            // return s;
+        } catch (TencentCloudSDKException e) {
+            log.error("照片人脸核身失败: " + e.getMessage());
+            return "";
+        }
+    }
+
+    /**
+     * 活体人脸核身(视频 + 照片)(未使用)
+     *
+     * @param imageBase64
+     * @param videoBase64
+     * @return
+     */
+    public static String liveFaceContrast(String imageBase64, String videoBase64) {
+        JSONObject obj = new JSONObject();
+        obj.put("ImageBase64", imageBase64);
+        obj.put("VideoBase64", videoBase64);
+        obj.put("LivenessType", "ACTION");
+        obj.put("ValidateData", "1,2");
+        try {
+            Credential cred = new Credential(SECRET_ID, SECRET_KEY);;
+
+            HttpProfile httpProfile = new HttpProfile();
+            httpProfile.setEndpoint("faceid.tencentcloudapi.com");
+
+            ClientProfile clientProfile = new ClientProfile();
+            clientProfile.setHttpProfile(httpProfile);
+
+            FaceidClient client = new FaceidClient(cred, "ap-shanghai", clientProfile);
+
+            String params = obj.toJSONString();
+            LivenessCompareRequest req = LivenessCompareRequest.fromJsonString(params, LivenessCompareRequest.class);
+
+            LivenessCompareResponse resp = client.LivenessCompare(req);
+
+            String s = LivenessCompareResponse.toJsonString(resp);
+            return s;
+        } catch (TencentCloudSDKException e) {
+            log.error("活体人脸对比失败: " + e.getMessage());
+            return "";
+        }
+    }
+
+    /**
+     * 发送短信
+     * @param phone
+     * @param code
+     * @param time
+     * @return
+     */
+    public static String sendMsg(String phone, String code, String time) {
+        try {
+            /*
+             * 必要步骤: 实例化一个认证对象,入参需要传入腾讯云账户密钥对secretId,secretKey。
+             * 这里采用的是从环境变量读取的方式,需要在环境变量中先设置这两个值。 你也可以直接在代码中写死密钥对,但是小心不要将代码复制、上传或者分享给他人,
+             * 以免泄露密钥对危及你的财产安全。 CAM密匙查询: https://console.cloud.tencent.com/cam/capi
+             */
+            Credential cred = new Credential(SECRET_ID, SECRET_KEY);
+            // 实例化一个http选项,可选,没有特殊需求可以跳过
+            HttpProfile httpProfile = new HttpProfile();
+            // 设置代理
+            // httpProfile.setProxyHost("真实代理ip");
+            // httpProfile.setProxyPort(真实代理端口);
+            /*
+             * SDK默认使用POST方法。 如果你一定要使用GET方法,可以在这里设置。GET方法无法处理一些较大的请求
+             */
+            httpProfile.setReqMethod("POST");
+            /*
+             * SDK有默认的超时时间,非必要请不要进行调整 如有需要请在代码中查阅以获取最新的默认值
+             */
+            httpProfile.setConnTimeout(60);
+            /*
+             * SDK会自动指定域名。通常是不需要特地指定域名的,但是如果你访问的是金融区的服务 则必须手动指定域名,例如sms的上海金融区域名:
+             * sms.ap-shanghai-fsi.tencentcloudapi.com
+             */
+            httpProfile.setEndpoint("sms.tencentcloudapi.com");
+
+            /*
+             * 非必要步骤: 实例化一个客户端配置对象,可以指定超时时间等配置
+             */
+            ClientProfile clientProfile = new ClientProfile();
+            /*
+             * SDK默认用TC3-HMAC-SHA256进行签名 非必要请不要修改这个字段
+             */
+            clientProfile.setSignMethod("HmacSHA256");
+            clientProfile.setHttpProfile(httpProfile);
+            /*
+             * 实例化要请求产品(以sms为例)的client对象 第二个参数是地域信息,可以直接填写字符串ap-guangzhou,或者引用预设的常量
+             */
+            SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
+            /*
+             * 实例化一个请求对象,根据调用的接口和实际情况,可以进一步设置请求参数 你可以直接查询SDK源码确定接口有哪些属性可以设置
+             * 属性可能是基本类型,也可能引用了另一个数据结构 推荐使用IDE进行开发,可以方便的跳转查阅各个接口和数据结构的文档说明
+             */
+            SendSmsRequest req = new SendSmsRequest();
+            /*
+             * 填充请求参数,这里request对象的成员变量即对应接口的入参 你可以通过官网接口文档或跳转到request对象的定义处查看请求参数的定义
+             * 基本类型的设置: 帮助链接: 短信控制台: https://console.cloud.tencent.com/smsv2 sms helper:
+             * https://cloud.tencent.com/document/product/382/3773
+             */
+            /* 短信应用ID: 短信SdkAppId在 [短信控制台] 添加应用后生成的实际SdkAppId,示例如1400006666 */
+            String sdkAppId = "1400625259";
+            req.setSmsSdkAppId(sdkAppId);
+
+            /* 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名,签名信息可登录 [短信控制台] 查看 */
+            String signName = "苏州展翼天创数字科技有限";
+            req.setSignName(signName);
+
+            /* 国际/港澳台短信 SenderId: 国内短信填空,默认未开通,如需开通请联系 [sms helper] */
+            String senderid = "";
+            req.setSenderId(senderid);
+
+            /* 用户的 session 内容: 可以携带用户侧 ID 等上下文信息,server 会原样返回 */
+            String sessionContext = "xxx";
+            req.setSessionContext(sessionContext);
+
+            /* 短信号码扩展号: 默认未开通,如需开通请联系 [sms helper] */
+            String extendCode = "";
+            req.setExtendCode(extendCode);
+
+            /* 模板 ID: 必须填写已审核通过的模板 ID。模板ID可登录 [短信控制台] 查看 */
+            String templateId = "1281636";
+            req.setTemplateId(templateId);
+
+            /*
+             * 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号] 示例如:+8613711112222, 其中前面有一个+号
+             * ,86为国家码,13711112222为手机号,最多不要超过200个手机号
+             */
+            String[] phoneNumberSet = { phone };
+            req.setPhoneNumberSet(phoneNumberSet);
+
+            /* 模板参数: 若无模板参数,则设置为空 */
+            String[] templateParamSet = { code, time };
+            req.setTemplateParamSet(templateParamSet);
+
+            /*
+             * 通过 client 对象调用 SendSms 方法发起请求。注意请求方法名与请求对象是对应的 返回的 res 是一个 SendSmsResponse
+             * 类的实例,与请求对象对应
+             */
+            SendSmsResponse res = client.SendSms(req);
+            return SendSmsResponse.toJsonString(res);
+            // 输出json格式的字符串回包
+            // System.out.println();
+            // 也可以取出单个值,你可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
+            // System.out.println(res.getRequestId());
+        } catch (TencentCloudSDKException e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
      * 输出文件
      * @param multipartFile
      * @param fileName

+ 0 - 164
eladmin-system/src/main/java/me/zhengjie/base/util/TencentUtil.java

@@ -1,164 +0,0 @@
-package me.zhengjie.base.util;
-
-import com.alibaba.fastjson.JSONObject;
-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.*;
-import com.tencentcloudapi.iai.v20200303.IaiClient;
-import com.tencentcloudapi.iai.v20200303.models.CompareFaceRequest;
-import com.tencentcloudapi.iai.v20200303.models.CompareFaceResponse;
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-public class TencentUtil {
-	// 展翼天创
-	private static final String SECRET_ID = "AKIDCD2b091cvxiDRP6VeX9VaOvBAsKVQ4SZ";
-	private static final String SECRET_KEY = "qPhjUyA5j6C1ZqqZ2D7k8bniLhma7NQH";
-
-	/**
-	 * 人脸比对(未使用)
-	 *
-	 * @param imageA
-	 * @param urlB
-	 * @return
-	 */
-	public static String compareFace(String imageA, String urlB) {
-		try {
-
-			Credential cred = new Credential(SECRET_ID, SECRET_KEY);
-
-			HttpProfile httpProfile = new HttpProfile();
-			httpProfile.setEndpoint("iai.tencentcloudapi.com");
-
-			ClientProfile clientProfile = new ClientProfile();
-			clientProfile.setHttpProfile(httpProfile);
-
-			IaiClient client = new IaiClient(cred, "ap-shanghai", clientProfile);
-			JSONObject paramObj = new JSONObject();
-			paramObj.put("ImageA", imageA);
-			paramObj.put("UrlB", urlB);
-//            log.info("需验证图片: " + imageA);
-			log.info("业务底照地址: " + urlB);
-			CompareFaceRequest req = CompareFaceRequest.fromJsonString(paramObj.toJSONString(),
-					CompareFaceRequest.class);
-			CompareFaceResponse resp = client.CompareFace(req);
-			String resultStr = CompareFaceResponse.toJsonString(resp);
-			log.info("人脸对比检测结果: " + resultStr);
-			return resultStr;
-		} catch (TencentCloudSDKException e) {
-			log.error("人脸对比发生错误,异常: " + e.getMessage());
-			return "";
-		}
-	}
-
-	/**
-	 * 活体人脸核身(视频 + 姓名 + 证件号码)(未使用)
-	 *
-	 * @param idCard
-	 * @param name
-	 * @param videoBase64
-	 */
-	public static String FaceNuclearBody(String idCard, String name, String videoBase64) {
-		JSONObject obj = new JSONObject();
-		obj.put("IdCard", idCard);
-		obj.put("Name", name);
-		obj.put("VideoBase64", videoBase64);
-		obj.put("LivenessType", "ACTION");
-		obj.put("ValidateData", "1,2");
-		try {
-			Credential cred = new Credential(SECRET_ID, SECRET_KEY);
-			HttpProfile httpProfile = new HttpProfile();
-			httpProfile.setEndpoint("faceid.tencentcloudapi.com");
-
-			ClientProfile clientProfile = new ClientProfile();
-			clientProfile.setHttpProfile(httpProfile);
-
-			FaceidClient client = new FaceidClient(cred, "ap-shanghai", clientProfile);
-
-			String params = obj.toJSONString();
-			LivenessRecognitionRequest req = LivenessRecognitionRequest.fromJsonString(params,
-					LivenessRecognitionRequest.class);
-			LivenessRecognitionResponse resp = client.LivenessRecognition(req);
-			return LivenessRecognitionResponse.toJsonString(resp);
-			// return s;
-		} catch (TencentCloudSDKException e) {
-			log.error("活体人脸核身失败: " + e.getMessage());
-			return "";
-		}
-	}
-
-
-	/**
-	 * 照片人脸核身(照片 + 姓名 + 证件号码)(已使用)
-	 *
-	 * @param idCard
-	 * @param name
-	 * @param ImageBase64
-	 */
-	public static String FaceImageBody(String idCard, String name, String ImageBase64) {
-		try {
-			Credential cred = new Credential(SECRET_ID, SECRET_KEY);;
-			HttpProfile httpProfile = new HttpProfile();
-			httpProfile.setEndpoint("faceid.tencentcloudapi.com");
-
-			ClientProfile clientProfile = new ClientProfile();
-			clientProfile.setHttpProfile(httpProfile);
-
-			FaceidClient client = new FaceidClient(cred, "ap-shanghai", clientProfile);
-
-			ImageRecognitionRequest req = new ImageRecognitionRequest();
-			req.setIdCard(idCard);
-			req.setName(name);
-			req.setImageBase64(ImageBase64);
-			ImageRecognitionResponse resp = client.ImageRecognition(req);
-			return ImageRecognitionResponse.toJsonString(resp);
-			// return s;
-		} catch (TencentCloudSDKException e) {
-			log.error("照片人脸核身失败: " + e.getMessage());
-			return "";
-		}
-	}
-
-
-
-	/**
-	 * 活体人脸核身(视频 + 照片)(未使用)
-	 *
-	 * @param imageBase64
-	 * @param videoBase64
-	 * @return
-	 */
-	public static String liveFaceContrast(String imageBase64, String videoBase64) {
-		JSONObject obj = new JSONObject();
-		obj.put("ImageBase64", imageBase64);
-		obj.put("VideoBase64", videoBase64);
-		obj.put("LivenessType", "ACTION");
-		obj.put("ValidateData", "1,2");
-		try {
-			Credential cred = new Credential(SECRET_ID, SECRET_KEY);;
-
-			HttpProfile httpProfile = new HttpProfile();
-			httpProfile.setEndpoint("faceid.tencentcloudapi.com");
-
-			ClientProfile clientProfile = new ClientProfile();
-			clientProfile.setHttpProfile(httpProfile);
-
-			FaceidClient client = new FaceidClient(cred, "ap-shanghai", clientProfile);
-
-			String params = obj.toJSONString();
-			LivenessCompareRequest req = LivenessCompareRequest.fromJsonString(params, LivenessCompareRequest.class);
-
-			LivenessCompareResponse resp = client.LivenessCompare(req);
-
-			String s = LivenessCompareResponse.toJsonString(resp);
-			return s;
-		} catch (TencentCloudSDKException e) {
-			log.error("活体人脸对比失败: " + e.getMessage());
-			return "";
-		}
-	}
-
-}