refactor: 对逻辑进行一些重构和优化

- 读取配置后对流进行关闭操作
- 代金券、优惠券批次类型现在是枚举类型
- 时间戳优化
This commit is contained in:
felord.cn
2021-01-16 23:38:29 +08:00
parent a584a65b25
commit c96e014273
6 changed files with 120 additions and 74 deletions

View File

@@ -32,10 +32,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.*;
/**
* @author felord.cn
@@ -78,9 +75,12 @@ public class AliPayConfiguration {
private String appRSAPrivateKey(String classPath) {
ClassPathResource resource = new ClassPathResource(classPath);
try {
File file = new ClassPathResource(classPath).getFile();
return new BufferedReader(new FileReader(file)).readLine();
FileReader in = new FileReader(resource.getFile());
try(BufferedReader bufferedReader = new BufferedReader(in)){
return bufferedReader.readLine();
}
} catch (IOException e) {
log.error("ali pay app private key is required ,{}", e.getMessage());
throw new PayException("ali pay app private key is required");