RtMallDynamicProperty.java
4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package com.diligrp.cashier.mall.property;
import com.diligrp.cashier.mall.exception.RtMartMallException;
import com.diligrp.cashier.mall.type.RtMarkErrorCode;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
/**
* @author dengwei
* @version 1.0.0
* @ClassName MallDynamicProperty.java
* @Description MallDynamicProperty
*/
@Configuration
@RefreshScope
@ConfigurationProperties(prefix = "rtmall.sign")
public class RtMallDynamicProperty {
@Value("${domain:}")
private String domain;
private List<AppSecretDynamicProperty> appSecrets;
public static class AppSecretDynamicProperty {
@Value("${source:1}")
private Integer source;
@Value("${orderType:3}")
private Integer orderType;
@Value("${appKey:}")
private String appKey;
@Value("${appSecret:}")
private String appSecret;
@Value("${companyCode:}")
private String companyCode;
@Value("${authUrl:https://hourh5-em-shop.feiniugo.com}")
private String authUrl;
@Value("${callbackDomain:}")
private String callbackDomain;
public Integer getSource() {
return source;
}
public void setSource(Integer source) {
this.source = source;
}
public String getAppKey() {
return appKey;
}
public void setAppKey(String appKey) {
this.appKey = appKey;
}
public String getAppSecret() {
return appSecret;
}
public void setAppSecret(String appSecret) {
this.appSecret = appSecret;
}
public String getAuthUrl() {
return authUrl;
}
public void setAuthUrl(String authUrl) {
this.authUrl = authUrl;
}
public Integer getOrderType() {
return orderType;
}
public void setOrderType(Integer orderType) {
this.orderType = orderType;
}
public String getCompanyCode() {
return companyCode;
}
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
}
public String getCallbackDomain() {
return callbackDomain;
}
public void setCallbackDomain(String callbackDomain) {
this.callbackDomain = callbackDomain;
}
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public List<AppSecretDynamicProperty> getAppSecrets() {
return appSecrets;
}
public void setAppSecrets(List<AppSecretDynamicProperty> appSecrets) {
this.appSecrets = appSecrets;
}
/**
* getBySource
*
*/
public AppSecretDynamicProperty getBySource(Integer source) {
return Optional.ofNullable(appSecrets)
.orElse(Collections.emptyList())
.stream()
.filter(item -> item.getSource().equals(source))
.findFirst()
.orElse(null);
}
/**
* getBySource
*
*/
public AppSecretDynamicProperty getBySourceAndType(Integer source, Integer orderType) {
return Optional.ofNullable(appSecrets)
.orElse(Collections.emptyList())
.stream()
.filter(item -> item.getSource().equals(source) && item.getOrderType().equals(orderType))
.findFirst()
.orElseThrow(() -> new RtMartMallException(RtMarkErrorCode.E5002));
}
/**
* getBySource
*
*/
public AppSecretDynamicProperty getByAppKey(String appKey) {
return Optional.ofNullable(appSecrets)
.orElse(Collections.emptyList())
.stream()
.filter(item -> item.getAppKey().equals(appKey))
.findFirst()
.orElse(null);
}
}