Skip to content

Commit

Permalink
spring-boot-starter upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
lunasaw committed Jun 1, 2021
1 parent fcd0485 commit 511c12e
Show file tree
Hide file tree
Showing 33 changed files with 294 additions and 283 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
/nbdist/
/.nb-gradle/
/build/

*/target/
# Project exclude paths
/api-spring-boot-starter/target/
4 changes: 2 additions & 2 deletions ali-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<parent>
<artifactId>fans-spring-boot-starter</artifactId>
<groupId>com.github.czy1024</groupId>
<version>2.0.3-RELEASE</version>
<version>2.1.0-RELEASE</version>
</parent>
<artifactId>ali-spring-boot-starter</artifactId>
<version>2.0.3-RELEASE</version>
<version>2.1.0-RELEASE</version>
<name>ali-spring-boot-starter</name>
<description>Ali API Toolkit Contain Oss And AliPay...</description>
<url>https://czy1024.github.io/fans-spring-boot-starter/ali-spring-boot-starter</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

/**
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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();
Expand All @@ -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<String, String[]> parameterMap = request.getParameterMap();
Map<String, String> reload = PayCheckFactory.reload(parameterMap);
return PayCheckFactory.check(reload, alipayConfigValue.getPublicKey());
return PayCheckFactory.check(reload, alipayConfigProperties.getPublicKey());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
@Component
@ConfigurationProperties(prefix = "luna.ali")
public class AliConfigValue {
public class AliOssConfigProperties {

private String ossId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
@Component
@ConfigurationProperties(prefix = "luna.alipay")
public class AlipayConfigValue {
public class AlipayConfigProperties {

private String appId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
Expand All @@ -54,12 +55,13 @@ public void createBucket(String bucketName, String accress, String type, AliConf
/**
* 列举所有的存储空间
*
* @param aliConfigValue
* @param aliOssConfigProperties
* @return
*/
public List<Bucket> listBuckets(String prefix, Integer maxKeys, String marker, AliConfigValue aliConfigValue) {
public List<Bucket> listBuckets(String prefix, Integer maxKeys, String marker,
AliOssConfigProperties aliOssConfigProperties) {
// 创建OSSClient实例。
OSS ossClient = aliConfigValue.getOssClient(false);
OSS ossClient = aliOssConfigProperties.getOssClient(false);

// 列举存储空间。
ListBucketsRequest listBucketsRequest = new ListBucketsRequest();
Expand Down Expand Up @@ -90,7 +92,7 @@ public List<Bucket> 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);
Expand All @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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);
// 获取存储空间的访问权限。
Expand All @@ -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);

Expand All @@ -210,7 +212,7 @@ public void deleteBucket(String bucketName, AliConfigValue configValue) {
* @param bucketName
* @param configValue
*/
public void setBucketTag(Map<String, String> tags, String bucketName, AliConfigValue configValue) {
public void setBucketTag(Map<String, String> tags, String bucketName, AliOssConfigProperties configValue) {
// 创建OSSClient实例。
OSS ossClient = configValue.getOssClient(false);

Expand All @@ -235,7 +237,7 @@ public void setBucketTag(Map<String, String> tags, String bucketName, AliConfigV
* @param configValue
* @return
*/
public Map<String, String> getBucketTags(String bucketName, AliConfigValue configValue) {
public Map<String, String> getBucketTags(String bucketName, AliOssConfigProperties configValue) {
// 创建OSSClient实例。
OSS ossClient = configValue.getOssClient(false);

Expand Down
Loading

0 comments on commit 511c12e

Please sign in to comment.