From 511c12e8c75f056b5d8e43ff6ade0e46babba48c Mon Sep 17 00:00:00 2001 From: luna Date: Tue, 1 Jun 2021 11:02:29 +0800 Subject: [PATCH] spring-boot-starter upgrade --- .gitignore | 2 +- ali-spring-boot-starter/pom.xml | 4 +- .../main/java/com/luna/ali/api/AlipayApi.java | 56 +++++++++--------- .../com/luna/ali/config/AliConfiguration.java | 13 +++-- ...Value.java => AliOssConfigProperties.java} | 2 +- ...Value.java => AlipayConfigProperties.java} | 2 +- .../com/luna/ali/oss/AliOssBucketApi.java | 32 ++++++----- .../com/luna/ali/oss/AliOssDownloadApi.java | 28 ++++----- .../com/luna/ali/oss/AliOssUploadApi.java | 12 ++-- .../com/luna/ali/oss/AliOssUploadGoOnApi.java | 16 +++--- .../java/com/luna/ali/oss/AliOssUtil.java | 6 +- .../com/luna/ali/oss/PostObjectSample.java | 14 ++--- .../com/luna/ali/service/AlipayService.java | 14 ++--- api-spring-boot-starter/pom.xml | 4 +- baidu-spring-boot-starter/pom.xml | 4 +- .../com/luna/baidu/api/BaiduVoiceApi.java | 14 +++++ .../com/luna/baidu/req/VoiceSynthesisReq.java | 2 + pom.xml | 2 +- tencent-spring-boot-starter/README.md | 23 +++----- tencent-spring-boot-starter/pom.xml | 4 +- .../tencent/config/TencentConfigValue.java | 49 ---------------- .../tencent/config/TencentConfiguration.java | 33 ++++++----- .../tencent/config/TencentPayConfigValue.java | 57 ------------------- ...java => TencentPayQueueConfiguration.java} | 9 +-- .../luna/tencent/pay/api/TencentPayApi.java | 22 +++---- .../tencent/pay/entity/TencentPayEntity.java | 7 +-- .../tencent/pay/mq/DelayMessageListener.java | 4 +- .../nortify/TencentPayNotifyController.java | 17 ++---- .../TencentApiConfigProperties.java | 52 +++++++++++++++++ .../TencentPayConfigProperties.java | 54 ++++++++++++++++++ .../TencentPayMqConfigProperties.java} | 4 +- .../main/resources/META-INF/spring.factories | 2 +- .../src/main/resources/application-pro.yml | 13 +++-- 33 files changed, 294 insertions(+), 283 deletions(-) rename ali-spring-boot-starter/src/main/java/com/luna/ali/config/{AliConfigValue.java => AliOssConfigProperties.java} (98%) rename ali-spring-boot-starter/src/main/java/com/luna/ali/config/{AlipayConfigValue.java => AlipayConfigProperties.java} (97%) delete mode 100644 tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentConfigValue.java delete mode 100644 tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentPayConfigValue.java rename tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/{TencentPayQueueConfig.java => TencentPayQueueConfiguration.java} (86%) create mode 100644 tencent-spring-boot-starter/src/main/java/com/luna/tencent/properties/TencentApiConfigProperties.java create mode 100644 tencent-spring-boot-starter/src/main/java/com/luna/tencent/properties/TencentPayConfigProperties.java rename tencent-spring-boot-starter/src/main/java/com/luna/tencent/{config/TencentPayMqConfigValue.java => properties/TencentPayMqConfigProperties.java} (91%) diff --git a/.gitignore b/.gitignore index 1c444066..e07ec4bf 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,6 @@ /nbdist/ /.nb-gradle/ /build/ - +*/target/ # Project exclude paths /api-spring-boot-starter/target/ \ No newline at end of file diff --git a/ali-spring-boot-starter/pom.xml b/ali-spring-boot-starter/pom.xml index 8156ef9a..d9c69150 100644 --- a/ali-spring-boot-starter/pom.xml +++ b/ali-spring-boot-starter/pom.xml @@ -7,10 +7,10 @@ fans-spring-boot-starter com.github.czy1024 - 2.0.3-RELEASE + 2.1.0-RELEASE ali-spring-boot-starter - 2.0.3-RELEASE + 2.1.0-RELEASE ali-spring-boot-starter Ali API Toolkit Contain Oss And AliPay... https://czy1024.github.io/fans-spring-boot-starter/ali-spring-boot-starter diff --git a/ali-spring-boot-starter/src/main/java/com/luna/ali/api/AlipayApi.java b/ali-spring-boot-starter/src/main/java/com/luna/ali/api/AlipayApi.java index 890cf0aa..8ebfd71f 100644 --- a/ali-spring-boot-starter/src/main/java/com/luna/ali/api/AlipayApi.java +++ b/ali-spring-boot-starter/src/main/java/com/luna/ali/api/AlipayApi.java @@ -9,7 +9,7 @@ import com.alipay.api.domain.AlipayTradeQueryModel; import com.luna.ali.alipay.factory.PayCheckFactory; import com.luna.ali.alipay.factory.PayRootChainFactory; -import com.luna.ali.config.AlipayConfigValue; +import com.luna.ali.config.AlipayConfigProperties; import com.luna.ali.dto.*; /** @@ -23,38 +23,38 @@ public class AlipayApi { /** * 网页支付 * - * @param alipayConfigValue + * @param alipayConfigProperties * @param alipayOrderDTO * @return * @throws AlipayApiException */ - public static String pagePay(AlipayConfigValue alipayConfigValue, AlipayOrderDTO alipayOrderDTO) + public static String pagePay(AlipayConfigProperties alipayConfigProperties, AlipayOrderDTO alipayOrderDTO) throws AlipayApiException { return PayRootChainFactory - .createdDevPayChain(alipayConfigValue.getAppId(), alipayConfigValue.getPrivateKey(), - alipayConfigValue.getPublicKey()) + .createdDevPayChain(alipayConfigProperties.getAppId(), alipayConfigProperties.getPrivateKey(), + alipayConfigProperties.getPublicKey()) .pagePay(alipayOrderDTO.getSubject(), alipayOrderDTO.getOutTradeNo(), alipayOrderDTO.getTotalAmount()) .builder() - .pay(alipayConfigValue.getReturnUrl(), alipayConfigValue.getNotifyUrl()); + .pay(alipayConfigProperties.getReturnUrl(), alipayConfigProperties.getNotifyUrl()); } /** * 交易查询 * - * @param alipayConfigValue + * @param alipayConfigProperties * @param queryOrderDTO * @return * @throws AlipayApiException */ - public static String payQuery(AlipayConfigValue alipayConfigValue, QueryOrderDTO queryOrderDTO) + public static String payQuery(AlipayConfigProperties alipayConfigProperties, QueryOrderDTO queryOrderDTO) throws AlipayApiException { AlipayTradeQueryModel queryModel = new AlipayTradeQueryModel(); queryModel.setOutTradeNo(queryOrderDTO.getOutTradeNo()); queryModel.setTradeNo(queryOrderDTO.getTradeNo()); queryModel.setQueryOptions(queryOrderDTO.getQueryOptions()); return PayRootChainFactory - .createdDevPayChain(alipayConfigValue.getAppId(), alipayConfigValue.getPrivateKey(), - alipayConfigValue.getPublicKey()) + .createdDevPayChain(alipayConfigProperties.getAppId(), alipayConfigProperties.getPrivateKey(), + alipayConfigProperties.getPublicKey()) .queryPay(queryModel) .builder() .query(); @@ -63,20 +63,20 @@ public static String payQuery(AlipayConfigValue alipayConfigValue, QueryOrderDTO /** * 关闭交易 * - * @param alipayConfigValue + * @param alipayConfigProperties * @param closeOrderDTO * @return * @throws AlipayApiException */ - public static String payClose(AlipayConfigValue alipayConfigValue, CloseOrderDTO closeOrderDTO) + public static String payClose(AlipayConfigProperties alipayConfigProperties, CloseOrderDTO closeOrderDTO) throws AlipayApiException { AlipayTradeCloseModel closeModel = new AlipayTradeCloseModel(); closeModel.setOutTradeNo(closeOrderDTO.getOutTradeNo()); closeModel.setTradeNo(closeOrderDTO.getTradeNo()); closeModel.setOperatorId(closeOrderDTO.getTradeNo()); return PayRootChainFactory - .createdDevPayChain(alipayConfigValue.getAppId(), alipayConfigValue.getPrivateKey(), - alipayConfigValue.getPublicKey()) + .createdDevPayChain(alipayConfigProperties.getAppId(), alipayConfigProperties.getPrivateKey(), + alipayConfigProperties.getPublicKey()) .closePay(closeModel) .builder() .close(); @@ -85,16 +85,16 @@ public static String payClose(AlipayConfigValue alipayConfigValue, CloseOrderDTO /** * 交易退款 * - * @param alipayConfigValue + * @param alipayConfigProperties * @param refundAmountDTO * @return * @throws AlipayApiException */ - public static String payRefund(AlipayConfigValue alipayConfigValue, RefundAmountDTO refundAmountDTO) + public static String payRefund(AlipayConfigProperties alipayConfigProperties, RefundAmountDTO refundAmountDTO) throws AlipayApiException { return PayRootChainFactory - .createdDevPayChain(alipayConfigValue.getAppId(), alipayConfigValue.getPrivateKey(), - alipayConfigValue.getPublicKey()) + .createdDevPayChain(alipayConfigProperties.getAppId(), alipayConfigProperties.getPrivateKey(), + alipayConfigProperties.getPublicKey()) .refundPay(refundAmountDTO.getOutTradeNo(), refundAmountDTO.getTradeNo(), refundAmountDTO.getRefundAmount(), refundAmountDTO.getRefundReason(), refundAmountDTO.getOutRequestNo()) .builder() @@ -104,16 +104,16 @@ public static String payRefund(AlipayConfigValue alipayConfigValue, RefundAmount /** * 退款查询 * - * @param alipayConfigValue + * @param alipayConfigProperties * @param refundQueryDTO * @return * @throws AlipayApiException */ - public static String payRefundQuery(AlipayConfigValue alipayConfigValue, RefundQueryDTO refundQueryDTO) + public static String payRefundQuery(AlipayConfigProperties alipayConfigProperties, RefundQueryDTO refundQueryDTO) throws AlipayApiException { return PayRootChainFactory - .createdDevPayChain(alipayConfigValue.getAppId(), alipayConfigValue.getPrivateKey(), - alipayConfigValue.getPublicKey()) + .createdDevPayChain(alipayConfigProperties.getAppId(), alipayConfigProperties.getPrivateKey(), + alipayConfigProperties.getPublicKey()) .refundQueryPay(refundQueryDTO.getOutTradeNo(), refundQueryDTO.getTradeNo(), refundQueryDTO.getOutRequestNo()) .builder() @@ -126,11 +126,11 @@ public static String payRefundQuery(AlipayConfigValue alipayConfigValue, RefundQ * @return * @throws AlipayApiException */ - public static String payDownloadQuery(AlipayConfigValue alipayConfigValue, QueryBillDTO queryBillDTO) + public static String payDownloadQuery(AlipayConfigProperties alipayConfigProperties, QueryBillDTO queryBillDTO) throws AlipayApiException { return PayRootChainFactory - .createdDevPayChain(alipayConfigValue.getAppId(), alipayConfigValue.getPrivateKey(), - alipayConfigValue.getPublicKey()) + .createdDevPayChain(alipayConfigProperties.getAppId(), alipayConfigProperties.getPrivateKey(), + alipayConfigProperties.getPublicKey()) .downloadQueryPay(queryBillDTO.getBillType(), queryBillDTO.getBillDate()) .builder() .downloadQuery(); @@ -139,15 +139,15 @@ public static String payDownloadQuery(AlipayConfigValue alipayConfigValue, Query /** * 支付验证 * - * @param alipayConfigValue + * @param alipayConfigProperties * @param request * @return * @throws AlipayApiException */ - public static boolean payCheck(AlipayConfigValue alipayConfigValue, HttpServletRequest request) + public static boolean payCheck(AlipayConfigProperties alipayConfigProperties, HttpServletRequest request) throws AlipayApiException { Map parameterMap = request.getParameterMap(); Map reload = PayCheckFactory.reload(parameterMap); - return PayCheckFactory.check(reload, alipayConfigValue.getPublicKey()); + return PayCheckFactory.check(reload, alipayConfigProperties.getPublicKey()); } } diff --git a/ali-spring-boot-starter/src/main/java/com/luna/ali/config/AliConfiguration.java b/ali-spring-boot-starter/src/main/java/com/luna/ali/config/AliConfiguration.java index c95255ee..53fc9332 100644 --- a/ali-spring-boot-starter/src/main/java/com/luna/ali/config/AliConfiguration.java +++ b/ali-spring-boot-starter/src/main/java/com/luna/ali/config/AliConfiguration.java @@ -12,15 +12,16 @@ */ @Configuration @ConditionalOnProperty(prefix = "luna.ali", name = "enable", havingValue = "true") -@EnableConfigurationProperties({AliConfigValue.class, AlipayConfigValue.class}) +@EnableConfigurationProperties({AliOssConfigProperties.class, AlipayConfigProperties.class}) public class AliConfiguration { - private final AliConfigValue aliConfigValue; + private final AliOssConfigProperties aliOssConfigProperties; - private final AlipayConfigValue alipayConfigValue; + private final AlipayConfigProperties alipayConfigProperties; - public AliConfiguration(AliConfigValue aliConfigValue, AlipayConfigValue alipayConfigValue) { - this.aliConfigValue = aliConfigValue; - this.alipayConfigValue = alipayConfigValue; + public AliConfiguration(AliOssConfigProperties aliOssConfigProperties, + AlipayConfigProperties alipayConfigProperties) { + this.aliOssConfigProperties = aliOssConfigProperties; + this.alipayConfigProperties = alipayConfigProperties; } } diff --git a/ali-spring-boot-starter/src/main/java/com/luna/ali/config/AliConfigValue.java b/ali-spring-boot-starter/src/main/java/com/luna/ali/config/AliOssConfigProperties.java similarity index 98% rename from ali-spring-boot-starter/src/main/java/com/luna/ali/config/AliConfigValue.java rename to ali-spring-boot-starter/src/main/java/com/luna/ali/config/AliOssConfigProperties.java index 7feb507a..88e14a27 100644 --- a/ali-spring-boot-starter/src/main/java/com/luna/ali/config/AliConfigValue.java +++ b/ali-spring-boot-starter/src/main/java/com/luna/ali/config/AliOssConfigProperties.java @@ -13,7 +13,7 @@ */ @Component @ConfigurationProperties(prefix = "luna.ali") -public class AliConfigValue { +public class AliOssConfigProperties { private String ossId; diff --git a/ali-spring-boot-starter/src/main/java/com/luna/ali/config/AlipayConfigValue.java b/ali-spring-boot-starter/src/main/java/com/luna/ali/config/AlipayConfigProperties.java similarity index 97% rename from ali-spring-boot-starter/src/main/java/com/luna/ali/config/AlipayConfigValue.java rename to ali-spring-boot-starter/src/main/java/com/luna/ali/config/AlipayConfigProperties.java index 4e9fc55f..a4b708f6 100644 --- a/ali-spring-boot-starter/src/main/java/com/luna/ali/config/AlipayConfigValue.java +++ b/ali-spring-boot-starter/src/main/java/com/luna/ali/config/AlipayConfigProperties.java @@ -11,7 +11,7 @@ */ @Component @ConfigurationProperties(prefix = "luna.alipay") -public class AlipayConfigValue { +public class AlipayConfigProperties { private String appId; diff --git a/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssBucketApi.java b/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssBucketApi.java index 46d7b706..a7453a84 100644 --- a/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssBucketApi.java +++ b/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssBucketApi.java @@ -7,7 +7,7 @@ import com.aliyun.oss.OSS; import com.aliyun.oss.model.*; -import com.luna.ali.config.AliConfigValue; +import com.luna.ali.config.AliOssConfigProperties; import org.apache.commons.lang3.StringUtils; /** @@ -26,11 +26,12 @@ public class AliOssBucketApi { * 只能包括小写字母、数字和短划线(-)。 * 必须以小写字母或者数字开头和结尾。 * 长度必须在3~63字节之间。 - * @param aliConfigValue + * @param aliOssConfigProperties */ - public void createBucket(String bucketName, String accress, String type, AliConfigValue aliConfigValue) { + public void createBucket(String bucketName, String accress, String type, + AliOssConfigProperties aliOssConfigProperties) { // 创建OSSClient实例。 - OSS ossClient = aliConfigValue.getOssClient(false); + OSS ossClient = aliOssConfigProperties.getOssClient(false); // 创建CreateBucketRequest对象。 CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName); @@ -54,12 +55,13 @@ public void createBucket(String bucketName, String accress, String type, AliConf /** * 列举所有的存储空间 * - * @param aliConfigValue + * @param aliOssConfigProperties * @return */ - public List listBuckets(String prefix, Integer maxKeys, String marker, AliConfigValue aliConfigValue) { + public List listBuckets(String prefix, Integer maxKeys, String marker, + AliOssConfigProperties aliOssConfigProperties) { // 创建OSSClient实例。 - OSS ossClient = aliConfigValue.getOssClient(false); + OSS ossClient = aliOssConfigProperties.getOssClient(false); // 列举存储空间。 ListBucketsRequest listBucketsRequest = new ListBucketsRequest(); @@ -90,7 +92,7 @@ public List listBuckets(String prefix, Integer maxKeys, String marker, A * @param configValue * @return */ - public boolean isBucket(String bucketName, AliConfigValue configValue) { + public boolean isBucket(String bucketName, AliOssConfigProperties configValue) { // 创建OSSClient实例。 OSS ossClient = configValue.getOssClient(false); @@ -109,7 +111,7 @@ public boolean isBucket(String bucketName, AliConfigValue configValue) { * @param configValue * @return */ - public String getBucketRegion(String bucketName, AliConfigValue configValue) { + public String getBucketRegion(String bucketName, AliOssConfigProperties configValue) { // 创建OSSClient实例。 OSS ossClient = configValue.getOssClient(false); String location = ossClient.getBucketLocation(bucketName); @@ -126,7 +128,7 @@ public String getBucketRegion(String bucketName, AliConfigValue configValue) { * @param configValue * @return */ - public BucketInfo getBucketInfo(String bucketName, AliConfigValue configValue) { + public BucketInfo getBucketInfo(String bucketName, AliOssConfigProperties configValue) { // 创建OSSClient实例。 OSS ossClient = configValue.getOssClient(false); @@ -156,7 +158,7 @@ public BucketInfo getBucketInfo(String bucketName, AliConfigValue configValue) { * 公共读 存储空间的拥有者和授权用户有该存储空间内的文件的读写权限,其他用户只有该存储空间内的文件的读权限。请谨慎使用该权限。 CannedAccessControlList.PublicRead * 公共读写 所有用户都有该存储空间内的文件的读写权限。请谨慎使用该权限。 CannedAccessControlList.PublicReadWrite */ - public void setBucketAccess(String bucketName, String access, AliConfigValue configValue) { + public void setBucketAccess(String bucketName, String access, AliOssConfigProperties configValue) { // 创建OSSClient实例。 OSS ossClient = configValue.getOssClient(false); @@ -175,7 +177,7 @@ public void setBucketAccess(String bucketName, String access, AliConfigValue con * @param configValue * @return */ - public String getBucketAccess(String bucketName, AliConfigValue configValue) { + public String getBucketAccess(String bucketName, AliOssConfigProperties configValue) { // 创建OSSClient实例。 OSS ossClient = configValue.getOssClient(false); // 获取存储空间的访问权限。 @@ -192,7 +194,7 @@ public String getBucketAccess(String bucketName, AliConfigValue configValue) { * @param bucketName * @param configValue */ - public void deleteBucket(String bucketName, AliConfigValue configValue) { + public void deleteBucket(String bucketName, AliOssConfigProperties configValue) { // 创建OSSClient实例。 OSS ossClient = configValue.getOssClient(false); @@ -210,7 +212,7 @@ public void deleteBucket(String bucketName, AliConfigValue configValue) { * @param bucketName * @param configValue */ - public void setBucketTag(Map tags, String bucketName, AliConfigValue configValue) { + public void setBucketTag(Map tags, String bucketName, AliOssConfigProperties configValue) { // 创建OSSClient实例。 OSS ossClient = configValue.getOssClient(false); @@ -235,7 +237,7 @@ public void setBucketTag(Map tags, String bucketName, AliConfigV * @param configValue * @return */ - public Map getBucketTags(String bucketName, AliConfigValue configValue) { + public Map getBucketTags(String bucketName, AliOssConfigProperties configValue) { // 创建OSSClient实例。 OSS ossClient = configValue.getOssClient(false); diff --git a/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssDownloadApi.java b/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssDownloadApi.java index ce769040..75742359 100644 --- a/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssDownloadApi.java +++ b/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssDownloadApi.java @@ -11,7 +11,7 @@ import com.aliyun.oss.model.DownloadFileResult; import com.aliyun.oss.model.GetObjectRequest; import com.aliyun.oss.model.OSSObject; -import com.luna.ali.config.AliConfigValue; +import com.luna.ali.config.AliOssConfigProperties; import com.luna.common.net.base.HttpBaseUtils; import org.apache.commons.lang3.StringUtils; @@ -29,13 +29,14 @@ public class AliOssDownloadApi { * * @param bucketName * @param objectName - * @param aliConfigValue + * @param aliOssConfigProperties * @return */ - public String downloadByStream(String bucketName, String objectName, AliConfigValue aliConfigValue) { + public String downloadByStream(String bucketName, String objectName, + AliOssConfigProperties aliOssConfigProperties) { // 创建OSSClient实例。 - OSS ossClient = aliConfigValue.getOssClient(false); + OSS ossClient = aliOssConfigProperties.getOssClient(false); // ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。 OSSObject ossObject = ossClient.getObject(bucketName, objectName); @@ -60,12 +61,13 @@ public String downloadByStream(String bucketName, String objectName, AliConfigVa * @param bucketName * @param objectName * @param loaclFile - * @param aliConfigValue + * @param aliOssConfigProperties */ - public void downloadByFile(String bucketName, String objectName, String loaclFile, AliConfigValue aliConfigValue) { + public void downloadByFile(String bucketName, String objectName, String loaclFile, + AliOssConfigProperties aliOssConfigProperties) { // 创建OSSClient实例。 - OSS ossClient = aliConfigValue.getOssClient(false); + OSS ossClient = aliOssConfigProperties.getOssClient(false); // 下载OSS文件到本地文件。如果指定的本地文件存在会覆盖,不存在则新建。 ossClient.getObject(new GetObjectRequest(bucketName, objectName), new File(loaclFile)); @@ -84,13 +86,13 @@ public void downloadByFile(String bucketName, String objectName, String loaclFil * @param bucketName * @param objectName * @param loaclFile - * @param aliConfigValue + * @param aliOssConfigProperties */ public void downloadByCondition(String bucketName, String objectName, String loaclFile, - AliConfigValue aliConfigValue) { + AliOssConfigProperties aliOssConfigProperties) { // 创建OSSClient实例。 - OSS ossClient = aliConfigValue.getOssClient(false); + OSS ossClient = aliOssConfigProperties.getOssClient(false); GetObjectRequest request = new GetObjectRequest(bucketName, objectName); // 设置限定条件。 @@ -111,13 +113,13 @@ public void downloadByCondition(String bucketName, String objectName, String loa * @param objectName * @param loaclFile * @param checkFile - * @param aliConfigValue + * @param aliOssConfigProperties */ public void downloadByGoOn(String bucketName, String objectName, String loaclFile, String checkFile, - AliConfigValue aliConfigValue) { + AliOssConfigProperties aliOssConfigProperties) { // 创建OSSClient实例。 - OSS ossClient = aliConfigValue.getOssClient(false); + OSS ossClient = aliOssConfigProperties.getOssClient(false); // 下载请求,10个任务并发下载,启动断点续传。 DownloadFileRequest downloadFileRequest = new DownloadFileRequest(bucketName, objectName); diff --git a/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssUploadApi.java b/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssUploadApi.java index 25e66f1f..c044a3b7 100644 --- a/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssUploadApi.java +++ b/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssUploadApi.java @@ -12,7 +12,7 @@ import com.aliyun.oss.OSS; import com.aliyun.oss.internal.OSSHeaders; import com.aliyun.oss.model.*; -import com.luna.ali.config.AliConfigValue; +import com.luna.ali.config.AliOssConfigProperties; /** * @Package: com.luna.ali.oss @@ -34,7 +34,7 @@ public class AliOssUploadApi { * @param configVale */ public static String uploadByFilePath(String filePath, String bucketName, String imgFolder, String access, - String type, AliConfigValue configVale) { + String type, AliOssConfigProperties configVale) { log.info("uploadByFilePath start filePath={},bucketName={},imgFolder={},access={},type={}", filePath, bucketName, imgFolder, access, type); // 创建PutObjectRequest对象。 @@ -72,7 +72,7 @@ public static String uploadByFilePath(String filePath, String bucketName, String * @param configVale */ public static void uploadByString(String content, String objectName, String imgFolder, String bucketName, - String access, String type, AliConfigValue configVale) { + String access, String type, AliOssConfigProperties configVale) { OSS ossClient = configVale.getOssClient(false); if (!imgFolder.endsWith("/")) { @@ -105,7 +105,7 @@ public static void uploadByString(String content, String objectName, String imgF */ public static void uploadByByteArray(byte[] content, String objectName, String imgFolder, String bucketName, String access, - String type, AliConfigValue configVale) { + String type, AliOssConfigProperties configVale) { OSS ossClient = configVale.getOssClient(false); if (!imgFolder.endsWith("/")) { @@ -138,7 +138,7 @@ public static void uploadByByteArray(byte[] content, String objectName, String i */ public static void uploadByURLStream(URL url, String objectName, String imgFolder, String bucketName, String access, - String type, AliConfigValue configVale) throws IOException { + String type, AliOssConfigProperties configVale) throws IOException { OSS ossClient = configVale.getOssClient(false); if (!imgFolder.endsWith("/")) { @@ -172,7 +172,7 @@ public static void uploadByURLStream(URL url, String objectName, String imgFolde */ public static void uploadByFileStream(FileInputStream fileInputStream, String objectName, String imgFolder, String bucketName, String access, - String type, AliConfigValue configVale) { + String type, AliOssConfigProperties configVale) { OSS ossClient = configVale.getOssClient(false); if (!imgFolder.endsWith("/")) { diff --git a/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssUploadGoOnApi.java b/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssUploadGoOnApi.java index 83c180af..660040c9 100644 --- a/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssUploadGoOnApi.java +++ b/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssUploadGoOnApi.java @@ -8,7 +8,7 @@ import com.aliyun.oss.model.AppendObjectResult; import com.aliyun.oss.model.ObjectMetadata; import com.aliyun.oss.model.UploadFileRequest; -import com.luna.ali.config.AliConfigValue; +import com.luna.ali.config.AliOssConfigProperties; import org.apache.commons.lang3.StringUtils; /** @@ -26,12 +26,12 @@ public class AliOssUploadGoOnApi { * @param bucketName * @param contents * @param objectName - * @param aliConfigValue + * @param aliOssConfigProperties */ public static void uploadGoOn(String bucketName, List contents, String objectName, - AliConfigValue aliConfigValue) { + AliOssConfigProperties aliOssConfigProperties) { // 创建OSSClient实例。 - OSS ossClient = aliConfigValue.getOssClient(false); + OSS ossClient = aliOssConfigProperties.getOssClient(false); ObjectMetadata meta = new ObjectMetadata(); // 指定上传的内容类型。 @@ -77,14 +77,14 @@ public static void uploadGoOn(String bucketName, List contents, String o * @param localFile * @param checkpointFile * @param objectName - * @param aliConfigValue + * @param aliOssConfigProperties * @throws Throwable */ public void uploadBreakPoint(String bucketName, String localFile, String checkpointFile, Integer taskNum, String objectName, - AliConfigValue aliConfigValue) throws Throwable { + AliOssConfigProperties aliOssConfigProperties) throws Throwable { // 创建OSSClient实例。 - OSS ossClient = aliConfigValue.getOssClient(false); + OSS ossClient = aliOssConfigProperties.getOssClient(false); ObjectMetadata meta = new ObjectMetadata(); // 指定上传的内容类型。 @@ -116,7 +116,7 @@ public void uploadBreakPoint(String bucketName, String localFile, String checkpo // 文件的元数据。 uploadFileRequest.setObjectMetadata(meta); // 设置上传成功回调,参数为Callback类型。 - uploadFileRequest.setCallback(AliOssUtil.getCallback(aliConfigValue.getServerUrl())); + uploadFileRequest.setCallback(AliOssUtil.getCallback(aliOssConfigProperties.getServerUrl())); // 断点续传上传。 ossClient.uploadFile(uploadFileRequest); diff --git a/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssUtil.java b/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssUtil.java index 1ae8f54b..0497fef2 100644 --- a/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssUtil.java +++ b/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/AliOssUtil.java @@ -8,7 +8,7 @@ import com.aliyun.oss.OSS; import com.aliyun.oss.internal.OSSHeaders; import com.aliyun.oss.model.*; -import com.luna.ali.config.AliConfigValue; +import com.luna.ali.config.AliOssConfigProperties; import com.luna.common.text.RandomStrUtil; import org.apache.commons.lang3.StringUtils; @@ -62,7 +62,7 @@ public static Callback getCallback(String serverUrl) { * @param configVale */ public static String ossUpload(String imagePath, String bucketName, String imgFolder, - AliConfigValue configVale) { + AliOssConfigProperties configVale) { // 创建PutObjectRequest对象。 File file = new File(imagePath); String fileName = file.getName(); @@ -92,7 +92,7 @@ public static String ossUpload(String imagePath, String bucketName, String imgFo * @param configVale * @return */ - public static OSS createOssWithCname(AliConfigValue configVale) { + public static OSS createOssWithCname(AliOssConfigProperties configVale) { return configVale.getOssClient(true); } diff --git a/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/PostObjectSample.java b/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/PostObjectSample.java index 86cab7da..5c5f4794 100644 --- a/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/PostObjectSample.java +++ b/ali-spring-boot-starter/src/main/java/com/luna/ali/oss/PostObjectSample.java @@ -12,7 +12,7 @@ import com.aliyun.oss.common.utils.BinaryUtil; import com.aliyun.oss.internal.OSSUtils; import com.aliyun.oss.model.Callback; -import com.luna.ali.config.AliConfigValue; +import com.luna.ali.config.AliOssConfigProperties; import com.luna.common.encrypt.HashUtils; import com.luna.common.text.Base64Util; @@ -23,13 +23,13 @@ public class PostObjectSample { * @param localFilePath 上传文件 * @param bucketName * @param objectName 设置文件名称 - * @param aliConfigValue + * @param aliOssConfigProperties * @throws Exception */ private void postObjectByForm(String localFilePath, String bucketName, String objectName, - AliConfigValue aliConfigValue) throws Exception { + AliOssConfigProperties aliOssConfigProperties) throws Exception { // 在URL中添加存储空间名称,添加后URL如下:http://yourBucketName.oss-cn-hangzhou.aliyuncs.com。 - String host = aliConfigValue.getHost().replace("http://", "http://" + bucketName + "."); + String host = aliOssConfigProperties.getHost().replace("http://", "http://" + bucketName + "."); // 设置表单Map。 Map formFields = new LinkedHashMap(); // 设置文件名称。 @@ -38,11 +38,11 @@ private void postObjectByForm(String localFilePath, String bucketName, String ob formFields.put("Content-Disposition", "attachment;filename=" + localFilePath); // 设置回调参数。 - Callback callback = AliOssUtil.getCallback(aliConfigValue.getServerUrl()); + Callback callback = AliOssUtil.getCallback(aliOssConfigProperties.getServerUrl()); // 在表单Map中设置回调参数。 setCallBack(formFields, callback); // 设置OSSAccessKeyId。 - formFields.put("OSSAccessKeyId", aliConfigValue.getOssId()); + formFields.put("OSSAccessKeyId", aliOssConfigProperties.getOssId()); String policy = "{\"expiration\": \"2120-01-01T12:00:00.000Z\",\"conditions\": [[\"content-length-range\", 0, 104857600]]}"; String encodePolicy = Base64Util.encodeBase64(policy.getBytes()); @@ -50,7 +50,7 @@ private void postObjectByForm(String localFilePath, String bucketName, String ob formFields.put("policy", encodePolicy); // 生成签名。 String signaturecom = - com.aliyun.oss.common.auth.ServiceSignature.create().computeSignature(aliConfigValue.getOssKey(), + com.aliyun.oss.common.auth.ServiceSignature.create().computeSignature(aliOssConfigProperties.getOssKey(), encodePolicy); // 设置签名。 formFields.put("Signature", signaturecom); diff --git a/ali-spring-boot-starter/src/main/java/com/luna/ali/service/AlipayService.java b/ali-spring-boot-starter/src/main/java/com/luna/ali/service/AlipayService.java index 1485f970..190f9a73 100644 --- a/ali-spring-boot-starter/src/main/java/com/luna/ali/service/AlipayService.java +++ b/ali-spring-boot-starter/src/main/java/com/luna/ali/service/AlipayService.java @@ -12,7 +12,7 @@ import com.alipay.api.AlipayApiException; import com.luna.ali.alipay.factory.PayCheckFactory; import com.luna.ali.api.AlipayApi; -import com.luna.ali.config.AlipayConfigValue; +import com.luna.ali.config.AlipayConfigProperties; import com.luna.ali.dto.*; import com.luna.common.dto.constant.ResultCode; @@ -28,7 +28,7 @@ public class AlipayService { private static final Logger log = LoggerFactory.getLogger(AlipayService.class); @Autowired - private AlipayConfigValue alipayConfigValue; + private AlipayConfigProperties alipayConfigProperties; /** * 支付接口 网页端自动跳转 @@ -40,7 +40,7 @@ public class AlipayService { public String createOrder(AlipayOrderDTO alipayOrderDTO) { log.info("createOrder start alipayOrderDTO={}", JSON.toJSONString(alipayOrderDTO)); try { - return AlipayApi.pagePay(alipayConfigValue, alipayOrderDTO); + return AlipayApi.pagePay(alipayConfigProperties, alipayOrderDTO); } catch (AlipayApiException e) { throw new BaseException(ResultCode.ERROR_SYSTEM_EXCEPTION, e.getMessage()); } @@ -56,7 +56,7 @@ public String createOrder(AlipayOrderDTO alipayOrderDTO) { public QueryOrderResultDTO queryOrder(QueryOrderDTO queryOrderDTO) { log.info("queryOrder start queryOrderDTO={}", JSON.toJSONString(queryOrderDTO)); try { - String response = JSON.parseObject(AlipayApi.payQuery(alipayConfigValue, queryOrderDTO)) + String response = JSON.parseObject(AlipayApi.payQuery(alipayConfigProperties, queryOrderDTO)) .getString("alipay_trade_query_response"); log.info("queryOrder success response={}", response); return JSON.parseObject(response, QueryOrderResultDTO.class); @@ -88,7 +88,7 @@ public void notifyOrder(Map data) { public String closeOrder(CloseOrderDTO closeOrderDTO) { log.info("closeOrder start closeOrderDTO={}", JSON.toJSONString(closeOrderDTO)); try { - String s = AlipayApi.payClose(alipayConfigValue, closeOrderDTO); + String s = AlipayApi.payClose(alipayConfigProperties, closeOrderDTO); log.info("closeOrder success s={}", JSON.toJSONString(s)); return s; } catch (AlipayApiException e) { @@ -105,7 +105,7 @@ public String closeOrder(CloseOrderDTO closeOrderDTO) { public String refundAmount(RefundAmountDTO refundAmountDTO) { log.info("refundAmount start refundAmountDTO={}", JSON.toJSONString(refundAmountDTO)); try { - String s = AlipayApi.payRefund(alipayConfigValue, refundAmountDTO); + String s = AlipayApi.payRefund(alipayConfigProperties, refundAmountDTO); log.info("closeOrder refundAmount s={}", JSON.toJSONString(s)); return s; } catch (AlipayApiException e) { @@ -122,7 +122,7 @@ public String refundAmount(RefundAmountDTO refundAmountDTO) { public String refundQuery(RefundQueryDTO refundQueryDTO) { log.info("refundQuery start refundQueryDTO={}", JSON.toJSONString(refundQueryDTO)); try { - String s = AlipayApi.payRefundQuery(alipayConfigValue, refundQueryDTO); + String s = AlipayApi.payRefundQuery(alipayConfigProperties, refundQueryDTO); log.info("refundQuery result s={}", JSON.toJSONString(s)); return s; } catch (AlipayApiException e) { diff --git a/api-spring-boot-starter/pom.xml b/api-spring-boot-starter/pom.xml index 5563d983..0bebfe49 100644 --- a/api-spring-boot-starter/pom.xml +++ b/api-spring-boot-starter/pom.xml @@ -5,10 +5,10 @@ fans-spring-boot-starter com.github.czy1024 - 2.0.3-RELEASE + 2.1.0-RELEASE 4.0.0 - 2.0.3-RELEASE + 2.1.0-RELEASE api-spring-boot-starter api-spring-boot-starter fans API Toolkit diff --git a/baidu-spring-boot-starter/pom.xml b/baidu-spring-boot-starter/pom.xml index ea98ff32..10aad999 100644 --- a/baidu-spring-boot-starter/pom.xml +++ b/baidu-spring-boot-starter/pom.xml @@ -7,11 +7,11 @@ fans-spring-boot-starter com.github.czy1024 - 2.0.3-RELEASE + 2.1.0-RELEASE baidu-spring-boot-starter baidu-spring-boot-starter - 2.0.3-RELEASE + 2.1.0-RELEASE Baidu API Toolkit https://czy1024.github.io/fans-spring-boot-starter/baidu-spring-boot-starter diff --git a/baidu-spring-boot-starter/src/main/java/com/luna/baidu/api/BaiduVoiceApi.java b/baidu-spring-boot-starter/src/main/java/com/luna/baidu/api/BaiduVoiceApi.java index c4170037..e76685f8 100644 --- a/baidu-spring-boot-starter/src/main/java/com/luna/baidu/api/BaiduVoiceApi.java +++ b/baidu-spring-boot-starter/src/main/java/com/luna/baidu/api/BaiduVoiceApi.java @@ -101,6 +101,20 @@ public static void voiceSynthesis(String tex, String tok, String savePath) { } } + /** + * 语音合成 + * + * @param voiceSynthesisReq 合成配置 + * @param savePath 保存目录 + */ + public static void voiceSynthesis(VoiceSynthesisReq voiceSynthesisReq, String savePath) { + try { + FileTools.write(voiceSynthesis(voiceSynthesisReq), savePath); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + /** * 语音合成 * diff --git a/baidu-spring-boot-starter/src/main/java/com/luna/baidu/req/VoiceSynthesisReq.java b/baidu-spring-boot-starter/src/main/java/com/luna/baidu/req/VoiceSynthesisReq.java index e5a96a91..caff29d3 100644 --- a/baidu-spring-boot-starter/src/main/java/com/luna/baidu/req/VoiceSynthesisReq.java +++ b/baidu-spring-boot-starter/src/main/java/com/luna/baidu/req/VoiceSynthesisReq.java @@ -41,6 +41,8 @@ public class VoiceSynthesisReq { private String tok; + public VoiceSynthesisReq() {} + public VoiceSynthesisReq(String cuid, String tex, String tok) { this.cuid = cuid; this.tex = tex; diff --git a/pom.xml b/pom.xml index 09e173c2..1a1c6b68 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.github.czy1024 fans-spring-boot-starter pom - 2.0.3-RELEASE + 2.1.0-RELEASE fans-spring-boot-starter fans API Toolkit https://czy1024.github.io/fans-spring-boot-starter diff --git a/tencent-spring-boot-starter/README.md b/tencent-spring-boot-starter/README.md index 4dfc4c8c..f7bd9470 100644 --- a/tencent-spring-boot-starter/README.md +++ b/tencent-spring-boot-starter/README.md @@ -88,22 +88,15 @@ luna: skyEyeSecretkey: xxx #微信支付信息配置 - weixin: - appid: xxx + wechat: + # 应用ID + appId: xxx + # 公钥 partner: xxx - partnerkey: xxx - notifyurl: xxx -spring: - redis: - host: xxx - port: 6379 - password: xxx - rabbitmq: - host: xxx - port: 5672 - username: admin - password: xxx - + # 私钥 + partnerKey: xxx + # 异步通知URL + notifyUrl: xxx mq: pay: diff --git a/tencent-spring-boot-starter/pom.xml b/tencent-spring-boot-starter/pom.xml index dfec723d..c6625c62 100644 --- a/tencent-spring-boot-starter/pom.xml +++ b/tencent-spring-boot-starter/pom.xml @@ -6,10 +6,10 @@ fans-spring-boot-starter com.github.czy1024 - 2.0.3-RELEASE + 2.1.0-RELEASE tencent-spring-boot-starter - 2.0.3-RELEASE + 2.1.0-RELEASE tencent-spring-boot-starter Tencent API Toolkit https://czy1024.github.io/fans-spring-boot-starter/tencent-spring-boot-starter diff --git a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentConfigValue.java b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentConfigValue.java deleted file mode 100644 index 2117fc7b..00000000 --- a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentConfigValue.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.luna.tencent.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -@Component -@ConfigurationProperties(prefix = "luna.ten") -public class TencentConfigValue { - - private String secretid; - - private String secretKey; - - private String skyEyeSecretid; - - private String skyEyeSecretkey; - - public String getSecretid() { - return secretid; - } - - public void setSecretid(String secretid) { - this.secretid = secretid; - } - - public String getSecretKey() { - return secretKey; - } - - public void setSecretKey(String secretKey) { - this.secretKey = secretKey; - } - - public String getSkyEyeSecretid() { - return skyEyeSecretid; - } - - public void setSkyEyeSecretid(String skyEyeSecretid) { - this.skyEyeSecretid = skyEyeSecretid; - } - - public String getSkyEyeSecretkey() { - return skyEyeSecretkey; - } - - public void setSkyEyeSecretkey(String skyEyeSecretkey) { - this.skyEyeSecretkey = skyEyeSecretkey; - } -} \ No newline at end of file diff --git a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentConfiguration.java b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentConfiguration.java index b396b235..a8dfdbf0 100644 --- a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentConfiguration.java +++ b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentConfiguration.java @@ -1,5 +1,8 @@ package com.luna.tencent.config; +import com.luna.tencent.properties.TencentApiConfigProperties; +import com.luna.tencent.properties.TencentPayConfigProperties; +import com.luna.tencent.properties.TencentPayMqConfigProperties; import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.BindingBuilder; import org.springframework.amqp.core.DirectExchange; @@ -19,29 +22,31 @@ */ @Configuration @ConditionalOnProperty(prefix = "luna.ten", name = "enable", havingValue = "true") -@EnableConfigurationProperties({TencentConfigValue.class, TencentPayConfigValue.class, TencentPayMqConfigValue.class}) +@EnableConfigurationProperties({TencentApiConfigProperties.class, TencentPayConfigProperties.class, + TencentPayMqConfigProperties.class}) public class TencentConfiguration { @Autowired - private TencentConfigValue tencentConfigValue; + private TencentApiConfigProperties tencentApiConfigProperties; @Autowired - private TencentPayConfigValue tencentPayConfigValue; + private TencentPayConfigProperties tencentPayConfigProperties; @Autowired - private TencentPayMqConfigValue tencentPayMqConfigValue; + private TencentPayMqConfigProperties tencentPayMqConfigProperties; - public TencentConfiguration(TencentConfigValue tencentConfigValue, TencentPayConfigValue tencentPayConfigValue, - TencentPayMqConfigValue tencentPayMqConfigValue) { - this.tencentConfigValue = tencentConfigValue; - this.tencentPayConfigValue = tencentPayConfigValue; - this.tencentPayMqConfigValue = tencentPayMqConfigValue; + public TencentConfiguration(TencentApiConfigProperties tencentApiConfigProperties, + TencentPayConfigProperties tencentPayConfigProperties, + TencentPayMqConfigProperties tencentPayMqConfigProperties) { + this.tencentApiConfigProperties = tencentApiConfigProperties; + this.tencentPayConfigProperties = tencentPayConfigProperties; + this.tencentPayMqConfigProperties = tencentPayMqConfigProperties; } @Bean @ConditionalOnMissingBean - public TencentPayQueueConfig tencentPayQueueConfig() { - return new TencentPayQueueConfig(); + public TencentPayQueueConfiguration tencentPayQueueConfig() { + return new TencentPayQueueConfiguration(); } /*** @@ -51,7 +56,7 @@ public TencentPayQueueConfig tencentPayQueueConfig() { */ @Bean public DirectExchange basicExchange() { - return new DirectExchange(tencentPayMqConfigValue.getExchange(), true, false); + return new DirectExchange(tencentPayMqConfigProperties.getExchange(), true, false); } /*** @@ -61,7 +66,7 @@ public DirectExchange basicExchange() { */ @Bean(name = "queueOrder") public Queue queueOrder() { - return new Queue(tencentPayMqConfigValue.getQueue(), true); + return new Queue(tencentPayMqConfigProperties.getQueue(), true); } /**** @@ -71,7 +76,7 @@ public Queue queueOrder() { */ @Bean public Binding basicBinding() { - return BindingBuilder.bind(queueOrder()).to(basicExchange()).with(tencentPayMqConfigValue.getRouting()); + return BindingBuilder.bind(queueOrder()).to(basicExchange()).with(tencentPayMqConfigProperties.getRouting()); } } diff --git a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentPayConfigValue.java b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentPayConfigValue.java deleted file mode 100644 index d8e8bfbf..00000000 --- a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentPayConfigValue.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.luna.tencent.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - * @Package: com.luna.tencent.config - * @ClassName: TencentPayConfigValue - * @Author: luna - * @CreateTime: 2020/8/16 14:18 - * @Description: - */ -@Component -@ConfigurationProperties(prefix = "luna.weixin") -public class TencentPayConfigValue { - - private String appid; - - private String partner; - - /** 密钥 */ - private String partnerkey; - - private String notifyurl; - - public String getAppid() { - return appid; - } - - public void setAppid(String appid) { - this.appid = appid; - } - - public String getPartner() { - return partner; - } - - public void setPartner(String partner) { - this.partner = partner; - } - - public String getPartnerkey() { - return partnerkey; - } - - public void setPartnerkey(String partnerkey) { - this.partnerkey = partnerkey; - } - - public String getNotifyurl() { - return notifyurl; - } - - public void setNotifyurl(String notifyurl) { - this.notifyurl = notifyurl; - } -} diff --git a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentPayQueueConfig.java b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentPayQueueConfiguration.java similarity index 86% rename from tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentPayQueueConfig.java rename to tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentPayQueueConfiguration.java index f5a03eba..4af102c7 100644 --- a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentPayQueueConfig.java +++ b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentPayQueueConfiguration.java @@ -4,15 +4,12 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; + /** - * @Package: com.luna.tencent.config - * @ClassName: TencentPayQueenConfig - * @Author: luna - * @CreateTime: 2020/8/17 16:22 - * @Description: + * @author luna */ @Configuration -public class TencentPayQueueConfig { +public class TencentPayQueueConfiguration { /** 创建Queue1 延时队列 会过期,过期后数据发送给Queue2 */ @Bean diff --git a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/api/TencentPayApi.java b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/api/TencentPayApi.java index 4a569cfe..00d7be9e 100644 --- a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/api/TencentPayApi.java +++ b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/api/TencentPayApi.java @@ -18,7 +18,7 @@ import com.google.common.collect.Maps; import com.luna.common.dto.constant.ResultCode; -import com.luna.tencent.config.TencentPayConfigValue; +import com.luna.tencent.properties.TencentPayConfigProperties; import com.luna.tencent.pay.constant.TencentPayConstant; import com.luna.tencent.pay.dto.CloseOderResultDTO; import com.luna.tencent.pay.dto.QueryResultDTO; @@ -43,25 +43,25 @@ public class TencentPayApi { * @return 支付二维码 * @throws Exception */ - public static String createNative(TencentPayConfigValue configValue, TencentPayEntity payEntity) { + public static String createNative(TencentPayConfigProperties configValue, TencentPayEntity payEntity) { log.info("createNative start configValue={},payEntity={}", JSON.toJSONString(configValue), JSON.toJSONString(payEntity)); HashMap paramMap = Maps.newHashMap(); // 2.设置参数值(根据文档来写) - paramMap.put("appid", configValue.getAppid()); + paramMap.put("appid", configValue.getAppId()); paramMap.put("mch_id", configValue.getPartner()); paramMap.put("nonce_str", RandomStrUtil.generateNonceStr()); paramMap.put("body", payEntity.getBody()); paramMap.put("out_trade_no", payEntity.getOutTradeNo()); paramMap.put("total_fee", payEntity.getTotalFee()); paramMap.put("spbill_create_ip", payEntity.getSpbillCreateIp()); - paramMap.put("notify_url", configValue.getNotifyurl()); + paramMap.put("notify_url", configValue.getNotifyUrl()); paramMap.put("trade_type", payEntity.getTradeType()); String codeUrl = null; try { - String body = SignUtil.generateSignedXml(paramMap, configValue.getPartnerkey()); + String body = SignUtil.generateSignedXml(paramMap, configValue.getPartnerKey()); HttpResponse httpResponse = HttpUtils.doPost(TencentPayConstant.HOST, TencentPayConstant.CREATE_ORDER, ImmutableMap.of(), null, body); @@ -83,19 +83,19 @@ public static String createNative(TencentPayConfigValue configValue, TencentPayE * @return * @throws Exception */ - public static QueryResultDTO queryStatus(TencentPayConfigValue configValue, String outTradeNo) { + public static QueryResultDTO queryStatus(TencentPayConfigProperties configValue, String outTradeNo) { log.info("queryStatus start outTradeNo={}", outTradeNo); Map paramMap = new HashMap<>(); // 2.设置参数值(根据文档来写) - paramMap.put("appid", configValue.getAppid()); + paramMap.put("appid", configValue.getAppId()); paramMap.put("mch_id", configValue.getPartner()); paramMap.put("nonce_str", RandomStrUtil.generateNonceStr()); paramMap.put("out_trade_no", outTradeNo); QueryResultDTO queryResultDTO = null; try { - String body = SignUtil.generateSignedXml(paramMap, configValue.getPartnerkey()); + String body = SignUtil.generateSignedXml(paramMap, configValue.getPartnerKey()); HttpResponse httpResponse = HttpUtils.doPost(TencentPayConstant.HOST, TencentPayConstant.QUERY_ORDER, ImmutableMap.of(), null, body); @@ -117,11 +117,11 @@ public static QueryResultDTO queryStatus(TencentPayConfigValue configValue, Stri * @return * @throws Exception */ - public static CloseOderResultDTO closeOrder(TencentPayConfigValue configValue, String outTradeNo) { + public static CloseOderResultDTO closeOrder(TencentPayConfigProperties configValue, String outTradeNo) { log.info("closeOrder start outTradeNo={}", outTradeNo); Map paramMap = new HashMap<>(); // 2.设置参数值(根据文档来写) - paramMap.put("appid", configValue.getAppid()); + paramMap.put("appid", configValue.getAppId()); paramMap.put("mch_id", configValue.getPartner()); paramMap.put("nonce_str", RandomStrUtil.generateNonceStr()); paramMap.put("out_trade_no", outTradeNo); @@ -129,7 +129,7 @@ public static CloseOderResultDTO closeOrder(TencentPayConfigValue configValue, S CloseOderResultDTO closeOderResultDTO = null; try { - String body = SignUtil.generateSignedXml(paramMap, configValue.getPartnerkey()); + String body = SignUtil.generateSignedXml(paramMap, configValue.getPartnerKey()); HttpResponse httpResponse = HttpUtils.doPost(TencentPayConstant.HOST, TencentPayConstant.CLOSE_ORDER, ImmutableMap.of(), null, body); diff --git a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/entity/TencentPayEntity.java b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/entity/TencentPayEntity.java index f108e5dc..ce14ff3c 100644 --- a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/entity/TencentPayEntity.java +++ b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/entity/TencentPayEntity.java @@ -1,11 +1,8 @@ package com.luna.tencent.pay.entity; + /** - * @Package: com.luna.tencent.pay.entity - * @ClassName: PayEntity - * @Author: luna - * @CreateTime: 2020/8/16 14:23 - * @Description: + * @author luna */ public class TencentPayEntity { /** 商品描述 */ diff --git a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/mq/DelayMessageListener.java b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/mq/DelayMessageListener.java index ec9b97b0..916f88a3 100644 --- a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/mq/DelayMessageListener.java +++ b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/mq/DelayMessageListener.java @@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import com.luna.tencent.config.TencentPayConfigValue; +import com.luna.tencent.properties.TencentPayConfigProperties; import com.luna.tencent.pay.api.TencentPayApi; /** @@ -20,7 +20,7 @@ public class DelayMessageListener { @Autowired - private TencentPayConfigValue configValue; + private TencentPayConfigProperties configValue; /** * 延时队列监听 diff --git a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/nortify/TencentPayNotifyController.java b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/nortify/TencentPayNotifyController.java index 5ed7094e..58ee8ba8 100644 --- a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/nortify/TencentPayNotifyController.java +++ b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/pay/nortify/TencentPayNotifyController.java @@ -2,13 +2,10 @@ import javax.servlet.http.HttpServletRequest; -import com.luna.common.date.DateUtil; import com.luna.common.dto.constant.ResultCode; import com.luna.common.exception.BaseException; -import com.luna.common.net.HttpUtils; import com.luna.common.net.base.HttpBaseUtils; -import com.luna.tencent.config.TencentPayMqConfigValue; -import org.apache.commons.io.FileUtils; +import com.luna.tencent.properties.TencentPayMqConfigProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.amqp.AmqpException; @@ -16,15 +13,12 @@ import org.springframework.amqp.core.MessagePostProcessor; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; import org.springframework.web.bind.annotation.*; -import com.luna.tencent.config.TencentPayConfigValue; +import com.luna.tencent.properties.TencentPayConfigProperties; import com.luna.tencent.pay.api.TencentPayApi; import com.luna.tencent.pay.entity.TencentPayEntity; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; /** * @Package: com.luna.tencent.pay.nortify @@ -40,10 +34,10 @@ public class TencentPayNotifyController { private RabbitTemplate rabbitTemplate; @Autowired - private TencentPayMqConfigValue tencentPayMqConfigValue; + private TencentPayMqConfigProperties tencentPayMqConfigProperties; @Autowired - private TencentPayConfigValue configValue; + private TencentPayConfigProperties configValue; private static final Logger log = LoggerFactory.getLogger(TencentPayNotifyController.class); @@ -56,7 +50,8 @@ public class TencentPayNotifyController { public String notify(HttpServletRequest request) { String data = getRequest(request); // Mq监听处理 - rabbitTemplate.convertAndSend(tencentPayMqConfigValue.getExchange(), tencentPayMqConfigValue.getRouting(), + rabbitTemplate.convertAndSend(tencentPayMqConfigProperties.getExchange(), + tencentPayMqConfigProperties.getRouting(), data); return TencentPayApi.retrunOrder("SUCCESS", "OK"); } diff --git a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/properties/TencentApiConfigProperties.java b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/properties/TencentApiConfigProperties.java new file mode 100644 index 00000000..cd009e6a --- /dev/null +++ b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/properties/TencentApiConfigProperties.java @@ -0,0 +1,52 @@ +package com.luna.tencent.properties; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * @author luna + */ +@Component +@ConfigurationProperties(prefix = "luna.ten") +public class TencentApiConfigProperties { + + private String secretId; + + private String secretKey; + + private String skyEyeSecretId; + + private String skyEyeSecretKey; + + public String getSecretId() { + return secretId; + } + + public void setSecretId(String secretId) { + this.secretId = secretId; + } + + public String getSecretKey() { + return secretKey; + } + + public void setSecretKey(String secretKey) { + this.secretKey = secretKey; + } + + public String getSkyEyeSecretId() { + return skyEyeSecretId; + } + + public void setSkyEyeSecretId(String skyEyeSecretId) { + this.skyEyeSecretId = skyEyeSecretId; + } + + public String getSkyEyeSecretKey() { + return skyEyeSecretKey; + } + + public void setSkyEyeSecretKey(String skyEyeSecretKey) { + this.skyEyeSecretKey = skyEyeSecretKey; + } +} \ No newline at end of file diff --git a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/properties/TencentPayConfigProperties.java b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/properties/TencentPayConfigProperties.java new file mode 100644 index 00000000..3ca4dee2 --- /dev/null +++ b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/properties/TencentPayConfigProperties.java @@ -0,0 +1,54 @@ +package com.luna.tencent.properties; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + + +/** + * @author luna + */ +@Component +@ConfigurationProperties(prefix = "luna.wechat") +public class TencentPayConfigProperties { + + private String appId; + + private String partner; + + /** 密钥 */ + private String partnerKey; + + private String notifyUrl; + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getPartner() { + return partner; + } + + public void setPartner(String partner) { + this.partner = partner; + } + + public String getPartnerKey() { + return partnerKey; + } + + public void setPartnerKey(String partnerKey) { + this.partnerKey = partnerKey; + } + + public String getNotifyUrl() { + return notifyUrl; + } + + public void setNotifyUrl(String notifyUrl) { + this.notifyUrl = notifyUrl; + } +} diff --git a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentPayMqConfigValue.java b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/properties/TencentPayMqConfigProperties.java similarity index 91% rename from tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentPayMqConfigValue.java rename to tencent-spring-boot-starter/src/main/java/com/luna/tencent/properties/TencentPayMqConfigProperties.java index 387a3873..082c7760 100644 --- a/tencent-spring-boot-starter/src/main/java/com/luna/tencent/config/TencentPayMqConfigValue.java +++ b/tencent-spring-boot-starter/src/main/java/com/luna/tencent/properties/TencentPayMqConfigProperties.java @@ -1,4 +1,4 @@ -package com.luna.tencent.config; +package com.luna.tencent.properties; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @@ -12,7 +12,7 @@ */ @Component @ConfigurationProperties(prefix = "mq.pay") -public class TencentPayMqConfigValue { +public class TencentPayMqConfigProperties { private String exchange; diff --git a/tencent-spring-boot-starter/src/main/resources/META-INF/spring.factories b/tencent-spring-boot-starter/src/main/resources/META-INF/spring.factories index dddb9c0e..ff9ce544 100644 --- a/tencent-spring-boot-starter/src/main/resources/META-INF/spring.factories +++ b/tencent-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -1,2 +1,2 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -com.luna.tencent.config.TencentConfiguration \ No newline at end of file +com.luna.tencent.config.TencentConfiguration diff --git a/tencent-spring-boot-starter/src/main/resources/application-pro.yml b/tencent-spring-boot-starter/src/main/resources/application-pro.yml index 51f3b8c9..47b4889f 100644 --- a/tencent-spring-boot-starter/src/main/resources/application-pro.yml +++ b/tencent-spring-boot-starter/src/main/resources/application-pro.yml @@ -1,6 +1,5 @@ luna: ten: - enable: true # 腾讯地图api mapKey: xxx # 腾讯api @@ -11,11 +10,15 @@ luna: skyEyeSecretkey: xxx #微信支付信息配置 - weixin: - appid: xxx + wechat: + # 应用ID + appId: xxx + # 公钥 partner: xxx - partnerkey: xxx - notifyurl: xxx + # 私钥 + partnerKey: xxx + # 异步通知URL + notifyUrl: xxx mq: pay: