Skip to content

Commit b327724

Browse files
committed
规范获取应用列表接口方法的相关字段命名
1 parent 6f9371d commit b327724

File tree

4 files changed

+22
-34
lines changed

4 files changed

+22
-34
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@ public WxCpAgentServiceImpl(WxCpService mainService) {
2323

2424
@Override
2525
public WxCpAgent get(Integer agentId) throws WxErrorException {
26-
27-
String url = "https://qyapi.weixin.qq.com/cgi-bin/agent/get";
28-
if (agentId != null) {
29-
url += "?agentid=" + agentId;
30-
} else {
26+
if (agentId == null) {
3127
throw new IllegalArgumentException("缺少agentid参数");
3228
}
29+
30+
String url = "https://qyapi.weixin.qq.com/cgi-bin/agent/get?agentid=" + agentId;
3331
String responseContent = this.mainService.get(url, null);
3432
return WxCpAgent.fromJson(responseContent);
3533
}

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
*/
1818
@Data
1919
public class WxCpAgent implements Serializable {
20+
private static final long serialVersionUID = 5002894979081127234L;
2021

2122
@SerializedName("errcode")
22-
private Integer errcode;
23+
private Integer errCode;
2324

2425
@SerializedName("errmsg")
25-
private String errmsg;
26+
private String errMsg;
2627

2728
@SerializedName("agentid")
28-
private Integer agentid;
29+
private Integer agentId;
2930

3031
@SerializedName("name")
3132
private String name;
@@ -37,10 +38,10 @@ public class WxCpAgent implements Serializable {
3738
private String description;
3839

3940
@SerializedName("allow_userinfos")
40-
private Users allowUserinfos;
41+
private Users allowUserInfos;
4142

4243
@SerializedName("allow_partys")
43-
private Partys allowPartys;
44+
private Partys allowParties;
4445

4546
@SerializedName("allow_tags")
4647
private Tags allowTags;
@@ -55,7 +56,7 @@ public class WxCpAgent implements Serializable {
5556
private Integer reportLocationFlag;
5657

5758
@SerializedName("isreportenter")
58-
private Integer isreportenter;
59+
private Integer isReportEnter;
5960

6061
@SerializedName("home_url")
6162
private String homeUrl;
@@ -71,26 +72,25 @@ public String toJson() {
7172
@Data
7273
public static class Users implements Serializable {
7374
@SerializedName("user")
74-
private List<User> user;
75+
private List<User> users;
7576
}
7677

77-
7878
@Data
7979
public class User implements Serializable {
8080
@SerializedName("userid")
81-
private String userid;
81+
private String userId;
8282
}
8383

8484
@Data
8585
public class Partys {
8686
@SerializedName("partyid")
87-
private List<Integer> partyids = null;
87+
private List<Integer> partyIds = null;
8888
}
8989

9090
@Data
9191
public class Tags {
9292
@SerializedName("tagid")
93-
private List<Integer> tagids = null;
93+
private List<Integer> tagIds = null;
9494
}
9595

9696
}

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImplTest.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
package me.chanjar.weixin.cp.api.impl;
22

3-
import com.google.inject.Inject;
4-
import me.chanjar.weixin.common.api.WxConsts;
5-
import me.chanjar.weixin.common.bean.menu.WxMenu;
6-
import me.chanjar.weixin.common.bean.menu.WxMenuButton;
7-
import me.chanjar.weixin.cp.api.ApiTestModule;
83
import me.chanjar.weixin.cp.api.WxCpAgentService;
94
import me.chanjar.weixin.cp.api.WxCpService;
105
import me.chanjar.weixin.cp.bean.WxCpAgent;
11-
import me.chanjar.weixin.cp.config.WxCpInMemoryConfigStorage;
12-
import org.mockito.Mock;
136
import org.testng.Assert;
14-
import org.testng.annotations.DataProvider;
15-
import org.testng.annotations.Guice;
167
import org.testng.annotations.Test;
178

18-
import static org.testng.Assert.assertEquals;
19-
import static org.testng.Assert.assertNotNull;
20-
import static org.mockito.Mockito.*;
9+
import static org.mockito.Mockito.mock;
10+
import static org.mockito.Mockito.when;
2111

2212

2313
/**
@@ -41,11 +31,11 @@ public void testGet() throws Exception {
4131
WxCpAgentService wxAgentService = this.wxService.getAgentService();
4232
WxCpAgent wxCpAgent = wxAgentService.get(9);
4333

44-
Assert.assertEquals(9, wxCpAgent.getAgentid().intValue());
34+
Assert.assertEquals(9, wxCpAgent.getAgentId().intValue());
4535

46-
Assert.assertEquals(new Integer[]{42762742}, wxCpAgent.getAllowPartys().getPartyids().toArray());
36+
Assert.assertEquals(new Integer[]{42762742}, wxCpAgent.getAllowParties().getPartyIds().toArray());
4737

48-
Assert.assertEquals(new Integer[]{23, 22, 35, 19, 32, 125, 133, 46, 150, 38, 183, 9, 7}, wxCpAgent.getAllowTags().getTagids().toArray());
38+
Assert.assertEquals(new Integer[]{23, 22, 35, 19, 32, 125, 133, 46, 150, 38, 183, 9, 7}, wxCpAgent.getAllowTags().getTagIds().toArray());
4939

5040
}
5141

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/WxCpAgentTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ public void testDeserialize() {
1414

1515
WxCpAgent wxCpAgent = WxCpAgent.fromJson(json);
1616

17-
Assert.assertEquals(9, wxCpAgent.getAgentid().intValue());
17+
Assert.assertEquals(9, wxCpAgent.getAgentId().intValue());
1818

19-
Assert.assertEquals(new Integer[]{42762742}, wxCpAgent.getAllowPartys().getPartyids().toArray());
19+
Assert.assertEquals(new Integer[]{42762742}, wxCpAgent.getAllowParties().getPartyIds().toArray());
2020

21-
Assert.assertEquals(new Integer[]{23, 22, 35, 19, 32, 125, 133, 46, 150, 38, 183, 9, 7}, wxCpAgent.getAllowTags().getTagids().toArray());
21+
Assert.assertEquals(new Integer[]{23, 22, 35, 19, 32, 125, 133, 46, 150, 38, 183, 9, 7}, wxCpAgent.getAllowTags().getTagIds().toArray());
2222

2323
}
2424

0 commit comments

Comments
 (0)