8000 Merge branch 'Wechat-Group:develop' into develop · binarywang/WxJava@fce2aa5 · GitHub < 8000 meta http-equiv="x-pjax-js-version" content="22b8ba371c22a1c35e16ecc7c5a3fa39814e3f6796c924c24aa174e743036571" data-turbo-track="reload">
[go: up one dir, main page]

Skip to content

Commit fce2aa5

Browse files
authored
Merge branch 'Wechat-Group:develop' into develop
2 parents 7def3d8 + e68477c commit fce2aa5

File tree

11 files changed

+110
-17
lines changed

11 files changed

+110
-17
lines changed

weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSessionManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public WxSession getSession(String sessionId, boolean create) {
9898

9999
// Create a new session if requested and the response is not committed
100100
if (!create) {
101-
return (null);
101+
return null;
102102
}
103103

104104
session = createSession(sessionId);
@@ -127,7 +127,7 @@ public void remove(InternalSession session, boolean update) {
127127
@Override
128128
public InternalSession findSession(String id) {
129129
if (id == null) {
130-
return (null);
130+
return null;
131131
}
132132
return this.sessions.get(id);
133133
}
@@ -251,7 +251,7 @@ public void processExpires() {
251251
if (this.log.isDebugEnabled()) {
252252
this.log.debug("End expire sessions {} processingTime {} expired sessions: {}", getName(), timeEnd - timeNow, expireHere);
253253
}
254-
this.processingTime += (timeEnd - timeNow);
254+
this.processingTime += timeEnd - timeNow;
255255

256256
}
257257

@@ -289,7 +289,7 @@ public void setBackgroundProcessorDelay(int backgroundProcessorDelay) {
289289
*/
290290
public String getName() {
291291

292-
return (name);
292+
return name;
293293

294294
}
295295

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/WxDnsResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
public class WxDnsResolver implements DnsResolver {
2020

2121
private final static String WECHAT_API_URL = "api.weixin.qq.com";
22-
private static Map<String, InetAddress[]> MAPPINGS = new HashMap<String, InetAddress[]>();
22+
private static Map<String, InetAddress[]> MAPPINGS = new HashMap<>();
2323
protected final Logger log = LoggerFactory.getLogger(WxDnsResolver.class);
2424
private String wxApiIp;
2525

@@ -38,7 +38,7 @@ private void init() {
3838
} catch (UnknownHostException e) {
3939
//如果初始化DNS配置失败则使用默认配置,不影响服务的启动
4040
log.error("init WxDnsResolver error", e);
41-
MAPPINGS = new HashMap<String, InetAddress[]>();
41+
MAPPINGS = new HashMap<>();
4242
}
4343

4444
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpService.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
99
import me.chanjar.weixin.common.util.http.RequestExecutor;
1010
import me.chanjar.weixin.common.util.http.RequestHttp;
11+
import me.chanjar.weixin.cp.bean.WxCpAgentJsapiSignature;
1112
import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult;
1213
import me.chanjar.weixin.cp.bean.WxCpProviderToken;
1314
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
@@ -124,6 +125,18 @@ public interface WxCpService extends WxService {
124125
*/
125126
WxJsapiSignature createJsapiSignature(String url) throws WxErrorException;
126127

128+
/**
129+
* <pre>
130+
* 创建调用wx.agentConfig时所需要的签名
131+
*
132+
* 详情请见:https://open.work.weixin.qq.com/api/doc/90000/90136/94313
133+
* </pre>
134+
*
135+
* @param url url
136+
* @return the agent jsapi signature
137+
* @throws WxErrorException
138+
*/
139+
WxCpAgentJsapiSignature createAgentJsapiSignature(String url) throws WxErrorException;
127140

128141
/**
129142
* 小程序登录凭证校验

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImpl.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import me.chanjar.weixin.common.util.http.*;
2121
import me.chanjar.weixin.common.util.json.GsonParser;
2222
import me.chanjar.weixin.cp.api.*;
23+
import me.chanjar.weixin.cp.bean.WxCpAgentJsapiSignature;
2324
import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult;
2425
import me.chanjar.weixin.cp.bean.WxCpProviderToken;
2526
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
@@ -171,6 +172,30 @@ public WxJsapiSignature createJsapiSignature(String url) throws WxErrorException
171172
return jsapiSignature;
172173
}
173174

175+
@Override
176+
public WxCpAgentJsapiSignature createAgentJsapiSignature(String url) throws WxErrorException {
177+
long timestamp = System.currentTimeMillis() / 1000;
178+
String noncestr = RandomUtils.getRandomStr();
179+
String jsapiTicket = getAgentJsapiTicket(false);
180+
String signature = SHA1.genWithAmple(
181+
"jsapi_ticket=" + jsapiTicket,
182+
"noncestr=" + noncestr,
183+
"timestamp=" + timestamp,
184+
"url=" + url
185+
);
186+
187+
WxCpAgentJsapiSignature jsapiSignature = new WxCpAgentJsapiSignature();
188+
jsapiSignature.setTimestamp(timestamp);
189+
jsapiSignature.setNonceStr(noncestr);
190+
jsapiSignature.setUrl(url);
191+
jsapiSignature.setSignature(signature);
192+
193+
jsapiSignature.setCorpid(this.configStorage.getCorpId());
194+
jsapiSignature.setAgentid(this.configStorage.getAgentId());
195+
196+
return jsapiSignature;
197+
}
198+
174199
@Override
175200
public WxCpMaJsCode2SessionResult jsCode2Session(String jsCode) throws WxErrorException {
176201
Map<String, String> params = new HashMap<>(2);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package me.chanjar.weixin.cp.bean;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
import java.io.Serializable;
9+
10+
/**
11+
* 调用wx.agentConfig时所需要的签名信息
12+
*/
13+
@Data
14+
@Builder
15+
@NoArgsConstructor
16+
@AllArgsConstructor
17+
public class WxCpAgentJsapiSignature implements Serializable {
18+
private static final long serialVersionUID = 2650119900835832545L;
19+
20+
private String url;
21+
22+
private String corpid;
23+
24+
private Integer agentid;
25+
26+
private long timestamp;
27+
28+
private String nonceStr;
29+
30+
private String signature;
31+
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAuthInfo.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@ public static class Agent implements Serializable {
152152
@Deprecated
153153
private String appid;
154154

155+
/**
156+
* 授权模式,0为管理员授权;1为成员授权
157+
*/
158+
@SerializedName("auth_mode")
159+
private Integer authMode;
160+
161+
/**
162+
* 是否为代开发自建应用
163+
*/
164+
@SerializedName("is_customized_app")
165+
private Boolean isCustomizedApp;
166+
155167
/**
156168
* 应用权限
157169
*/

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpPermanentCodeInfo.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,18 @@ public static class Agent implements Serializable {
151151
@Deprecated
152152
private String appid;
153153

154+
/**
155+
* 授权模式,0为管理员授权;1为成员授权
156+
*/
157+
@SerializedName("auth_mode")
158+
private Integer authMode;
159+
160+
/**
161+
* 是否为代开发自建应用
162+
*/
163+
@SerializedName("is_customized_app")
164+
private Boolean isCustomizedApp;
165+
154166
/**
155167
* 应用权限
156168
*/

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/AbstractWxMaRedisConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private String getValueFromRedis(String key) {
7979

8080
private void setValueToRedis(String key, long expiresTime, String value) {
8181
try (Jedis jedis = getConfiguredJedis()) {
82-
Map<String, String> hash = new HashMap<String, String>();
82+
Map<String, String> hash = new HashMap<>();
8383
hash.put(HASH_VALUE_FIELD, value);
8484
hash.put(HASH_EXPIRE_FIELD, String.valueOf(expiresTime));
8585
jedis.hmset(getRedisKey(key), hash);

weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaShopAuditServiceImplTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@ public void testAuditBrand() throws WxErrorException {
3333
WxMaShopAuditBrandRequest request = WxMaShopAuditBrandRequest.builder().build();
3434
WxMaShopAuditBrandRequest.AuditReqBean auditReqBean = WxMaShopAuditBrandRequest.AuditReqBean.builder().build();
3535

36-
auditReqBean.setLicense(new ArrayList<String>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")));
36+
auditReqBean.setLicense(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")));
3737
auditReqBean.setBrandInfo(WxMaShopAuditBrandRequest.AuditReqBean.BrandInfoBean.builder()
3838
.brandAuditType(1)
3939
.trademarkType("29")
4040
.brandManagementType(2)
4141
.commodityOriginType(2)
4242
.brandWording("346225226351203275")
43-
.saleAuthorization(new ArrayList<String>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
44-
.trademarkRegistrationCertificate(new ArrayList<String>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
45-
.trademarkChangeCertificate(new ArrayList<String>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
43+
.saleAuthorization(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
44+
.trademarkRegistrationCertificate(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
45+
.trademarkChangeCertificate(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
4646
.trademarkRegistrant("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")
4747
.trademarkRegistrantNu("1249305")
4848
.trademarkAuthorizationPeriod("2020-03-25 12:05:25")
49-
.trademarkRegistrationApplication(new ArrayList<String>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
49+
.trademarkRegistrationApplication(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
5050
.trademarkApplicant("张三")
5151
.trademarkApplicationTime("2020-03-25 12:05:25")
52-
.importedGoodsForm(new ArrayList<String>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
52+
.importedGoodsForm(new ArrayList<>(Arrays.asList("https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg")))
5353
.build());
5454
request.setAuditReq(auditReqBean);
5555

@@ -61,12 +61,12 @@ public void testAuditBrand() throws WxErrorException {
6161
public void testAuditCategory() throws WxErrorException {
6262
WxMaShopAuditCategoryRequest request = WxMaShopAuditCategoryRequest.builder().build();
6363
WxMaShopAuditCategoryRequest.AuditReqBean auditReqBean = WxMaShopAuditCategoryRequest.AuditReqBean.builder().build();
64-
auditReqBean.setLicense(new ArrayList<String>(Arrays.asList("www.xxxxx.com")));
64+
auditReqBean.setLicense(new ArrayList<>(Arrays.asList("www.xxxxx.com")));
6565
auditReqBean.setCategoryInfo(WxMaShopAuditCategoryRequest.AuditReqBean.CategoryInfoBean.builder()
6666
.level1(7419)
6767
.level2(7439)
6868
.level3(7448)
69-
.certificate(new ArrayList<String>(Arrays.asList("www.xxxxx.com")))
69+
.certificate(new ArrayList<>(Arrays.asList("www.xxxxx.com")))
7070
.build());
7171
request.setAuditReq(auditReqBean);
7272
WxMaShopAuditCategoryResponse response = wxService.getShopAuditService().auditCategory(request);

weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMessageRouter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public WxOpenMessageRouter(WxOpenService wxOpenService) {
1717
}
1818

1919
public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, String appId) {
20-
return route(wxMessage, new HashMap<String, Object>(), appId);
20+
return route(wxMessage, new HashMap<>(), appId);
2121
}
2222

2323
public WxMpXmlOutMessage route(final WxMpXmlMessage wxMessage, final Map<String, Object> context, String appId) {

0 commit comments

Comments
 (0)
0