0
# Development Tools
1
2
Development and management tools including code deployment, API management, plugin support, and testing utilities for WeChat MiniApp development workflow.
3
4
## Capabilities
5
6
### Code Management
7
8
Mini program code version control, deployment management, and code audit functionality.
9
10
```java { .api }
11
public interface WxMaCodeService {
12
// Version Control
13
boolean commitCode(String templateId, String userVersion, String userDesc, ExtJson extJson) throws WxErrorException;
14
WxMaCodeVersionsResult getCodeVersions() throws WxErrorException;
15
boolean releaseCode(String userVersion) throws WxErrorException;
16
boolean rollbackRelease() throws WxErrorException;
17
WxMaReleaseResult getRelease() throws WxErrorException;
18
19
// Code Auditing
20
WxMaSubmitAuditResult submitAudit() throws WxErrorException;
21
WxMaSubmitAuditResult submitAudit(List<WxMaCategory> categoryList) throws WxErrorException;
22
WxMaGetAuditStatusResult getAuditStatus(String auditId) throws WxErrorException;
23
WxMaGetLatestAuditStatusResult getLatestAuditStatus() throws WxErrorException;
24
boolean undoCodeAudit() throws WxErrorException;
25
26
// Testing & Preview
27
boolean setTestWhiteList(List<String> wechatidList) throws WxErrorException;
28
WxMaQrCodeResult getTestQrCode(String path, Map<String, String> queryParams) throws WxErrorException;
29
30
// Domain Management
31
boolean modifyDomain(String action, List<String> requestDomains, List<String> wsRequestDomains,
32
List<String> uploadDomains, List<String> downloadDomains) throws WxErrorException;
33
WxMaDomainResult getDomain() throws WxErrorException;
34
}
35
```
36
37
### JSAPI Configuration
38
39
JavaScript API configuration and signature management for WeChat MiniApp frontend integration.
40
41
```java { .api }
42
public interface WxMaJsapiService {
43
// JSAPI Ticket Management
44
String getJsapiTicket() throws WxErrorException;
45
String getJsapiTicket(boolean forceRefresh) throws WxErrorException;
46
47
// JS SDK Configuration
48
WxJsapiSignature createJsapiSignature(String url) throws WxErrorException;
49
50
// Card Extension Signatures
51
String getCardApiTicket() throws WxErrorException;
52
String getCardApiTicket(boolean forceRefresh) throws WxErrorException;
53
WxJsapiSignature createCardApiSignature(String... params) throws WxErrorException;
54
}
55
```
56
57
### Plugin Management
58
59
Plugin installation, configuration, and management for extending mini program functionality.
60
61
```java { .api }
62
public interface WxMaPluginService {
63
// Plugin Operations
64
boolean applyPlugin(String action, String pluginAppid, String reason) throws WxErrorException;
65
WxMaPluginListResult getPluginList() throws WxErrorException;
66
boolean setDevPluginList(String action, String appid, String userVersion) throws WxErrorException;
67
WxMaDevPluginResult getDevPlugin() throws WxErrorException;
68
69
// Plugin Development
70
boolean unbindPlugin(String action, String pluginAppid) throws WxErrorException;
71
WxMaPluginDevApplyListResult getPluginDevApplyList(Integer page, Integer num) throws WxErrorException;
72
}
73
```
74
75
### Open API Management
76
77
API quota monitoring, rate limiting management, and usage analytics for WeChat platform APIs.
78
79
```java { .api }
80
public interface WxMaOpenApiService {
81
// Quota Management
82
WxOpenMaQuotaGetResult getApiQuota(String cgiPath) throws WxErrorException;
83
WxOpenMaQueryQuotaResult queryQuota(String cgiPath) throws WxErrorException;
84
85
// Rate Limiting
86
boolean clearQuota(String appid, String cgiPath) throws WxErrorException;
87
88
// API Statistics
89
WxMaApiStatsResult getApiStats(Date startDate, Date endDate) throws WxErrorException;
90
List<WxMaApiQuotaInfo> getQuotaList() throws WxErrorException;
91
}
92
```
93
94
### Settings Management
95
96
Server configuration, member management, and application settings.
97
98
```java { .api }
99
public interface WxMaSettingService {
100
// Member Management
101
boolean bindTester(String wechatid) throws WxErrorException;
102
boolean unbindTester(String wechatid) throws WxErrorException;
103
WxMaMemberAuthResult getMemberAuth(String action) throws WxErrorException;
104
boolean modifyMemberAuth(String action, String auth) throws WxErrorException;
105
106
// Server Configuration
107
boolean modifyServerDomain(String action, List<String> requestDomains, List<String> wsRequestDomains,
108
List<String> uploadDomains, List<String> downloadDomains) throws WxErrorException;
109
WxMaServerDomainResult getServerDomain() throws WxErrorException;
110
111
// WebView Domain Configuration
112
boolean setWebViewDomain(String action, List<String> webViewDomains) throws WxErrorException;
113
WxMaWebViewDomainResult getWebViewDomain() throws WxErrorException;
114
}
115
```
116
117
## Data Models
118
119
### Code Management Models
120
121
Data models for code deployment and version management.
122
123
```java { .api }
124
public class WxMaSubmitAuditResult implements Serializable {
125
private String auditId; // Audit ID
126
127
public String getAuditId();
128
public void setAuditId(String auditId);
129
130
public static WxMaSubmitAuditResult fromJson(String json);
131
}
132
133
public class WxMaGetAuditStatusResult implements Serializable {
134
private Integer status; // Audit status (0: pending, 1: failed, 2: passed, 3: cancelled)
135
private String reason; // Failure reason
136
private Long auditId; // Audit ID
137
private String screenshot; // Screenshot URL
138
139
public Integer getStatus();
140
public void setStatus(Integer status);
141
public String getReason();
142
public void setReason(String reason);
143
public Long getAuditId();
144
public void setAuditId(Long auditId);
145
public String getScreenshot();
146
public void setScreenshot(String screenshot);
147
}
148
149
public class WxMaCodeVersionsResult implements Serializable {
150
private List<WxMaCodeVersion> codeVersions; // Code versions
151
152
public List<WxMaCodeVersion> getCodeVersions();
153
public void setCodeVersions(List<WxMaCodeVersion> codeVersions);
154
}
155
156
public class WxMaCodeVersion implements Serializable {
157
private String userVersion; // User version
158
private String userDesc; // Version description
159
private Long createTime; // Creation time
160
161
public String getUserVersion();
162
public void setUserVersion(String userVersion);
163
public String getUserDesc();
164
public void setUserDesc(String userDesc);
165
public Long getCreateTime();
166
public void setCreateTime(Long createTime);
167
}
168
```
169
170
### Plugin Models
171
172
Data models for plugin management.
173
174
```java { .api }
175
public class WxMaPluginListResult implements Serializable {
176
private List<WxMaPluginInfo> pluginList; // Plugin list
177
178
public List<WxMaPluginInfo> getPluginList();
179
public void setPluginList(List<WxMaPluginInfo> pluginList);
180
}
181
182
public class WxMaPluginInfo implements Serializable {
183
private String appid; // Plugin App ID
184
private Integer status; // Status
185
private String nickname; // Plugin name
186
private String headimgurl; // Plugin avatar
187
188
public String getAppid();
189
public void setAppid(String appid);
190
public Integer getStatus();
191
public void setStatus(Integer status);
192
public String getNickname();
193
public void setNickname(String nickname);
194
public String getHeadimgurl();
195
public void setHeadimgurl(String headimgurl);
196
}
197
```
198
199
### API Management Models
200
201
Data models for API quota and statistics management.
202
203
```java { .api }
204
public class WxOpenMaQuotaGetResult implements Serializable {
205
private Long quotaValue; // Quota limit
206
private Long usedQuota; // Used quota
207
private Long remainQuota; // Remaining quota
208
209
public Long getQuotaValue();
210
public void setQuotaValue(Long quotaValue);
211
public Long getUsedQuota();
212
public void setUsedQuota(Long usedQuota);
213
public Long getRemainQuota();
214
public void setRemainQuota(Long remainQuota);
215
}
216
217
public class WxOpenMaQueryQuotaResult implements Serializable {
218
private Integer errcode; // Error code
219
private String errmsg; // Error message
220
private WxOpenMaQuotaInfo quota; // Quota information
221
222
public Integer getErrcode();
223
public void setErrcode(Integer errcode);
224
public String getErrmsg();
225
public void setErrmsg(String errmsg);
226
public WxOpenMaQuotaInfo getQuota();
227
public void setQuota(WxOpenMaQuotaInfo quota);
228
}
229
```
230
231
## Usage Examples
232
233
### Code Deployment Workflow
234
235
```java
236
@Service
237
public class MiniProgramDeploymentService {
238
239
@Autowired
240
private WxMaService wxMaService;
241
242
public void deployNewVersion(String templateId, String version, String description) {
243
try {
244
WxMaCodeService codeService = wxMaService.getCodeService();
245
246
// 1. Commit code
247
ExtJson extJson = new ExtJson();
248
extJson.setExtAppid("your-appid");
249
extJson.setExt(Map.of("test", "value"));
250
251
boolean committed = codeService.commitCode(templateId, version, description, extJson);
252
if (!committed) {
253
throw new RuntimeException("Failed to commit code");
254
}
255
256
// 2. Submit for audit
257
List<WxMaCategory> categories = Arrays.asList(
258
new WxMaCategory(1, 2, "工具", "信息查询")
259
);
260
WxMaSubmitAuditResult auditResult = codeService.submitAudit(categories);
261
String auditId = auditResult.getAuditId();
262
263
// 3. Monitor audit status
264
WxMaGetAuditStatusResult status = codeService.getAuditStatus(auditId);
265
logger.info("Audit status: {}, reason: {}", status.getStatus(), status.getReason());
266
267
// 4. Release when approved (status == 2)
268
if (status.getStatus() == 2) {
269
boolean released = codeService.releaseCode(version);
270
if (released) {
271
logger.info("Version {} released successfully", version);
272
} else {
273
logger.error("Failed to release version {}", version);
274
}
275
}
276
277
} catch (WxErrorException e) {
278
logger.error("Deployment failed: {}", e.getMessage(), e);
279
throw new RuntimeException("Deployment failed", e);
280
}
281
}
282
}
283
```
284
285
### Plugin Management
286
287
```java
288
@Service
289
public class PluginManagementService {
290
291
@Autowired
292
private WxMaService wxMaService;
293
294
public void managePlugins() {
295
try {
296
WxMaPluginService pluginService = wxMaService.getPluginService();
297
298
// Apply for plugin
299
boolean applied = pluginService.applyPlugin("apply", "plugin-appid", "Need this plugin for functionality");
300
301
if (applied) {
302
// Get plugin list
303
WxMaPluginListResult result = pluginService.getPluginList();
304
for (WxMaPluginInfo plugin : result.getPluginList()) {
305
logger.info("Plugin: {} - {}, Status: {}",
306
plugin.getAppid(), plugin.getNickname(), plugin.getStatus());
307
}
308
309
// Set development plugin
310
pluginService.setDevPluginList("dev_add", "plugin-appid", "1.0.0");
311
}
312
313
} catch (WxErrorException e) {
314
logger.error("Plugin management failed: {}", e.getMessage(), e);
315
}
316
}
317
}
318
```
319
320
### API Quota Monitoring
321
322
```java
323
@Service
324
public class ApiQuotaService {
325
326
@Autowired
327
private WxMaService wxMaService;
328
329
@Scheduled(fixedRate = 300000) // Check every 5 minutes
330
public void monitorApiQuotas() {
331
try {
332
WxMaOpenApiService openApiService = wxMaService.getOpenApiService();
333
334
// Check critical API quotas
335
String[] criticalApis = {
336
"/cgi-bin/message/subscribe/send",
337
"/wxa/getwxacode",
338
"/cgi-bin/token"
339
};
340
341
for (String apiPath : criticalApis) {
342
WxOpenMaQuotaGetResult quota = openApiService.getApiQuota(apiPath);
343
344
long usagePercent = (quota.getUsedQuota() * 100) / quota.getQuotaValue();
345
346
if (usagePercent > 80) {
347
logger.warn("High API usage for {}: {}% ({}/{})",
348
apiPath, usagePercent,
349
quota.getUsedQuota(), quota.getQuotaValue());
350
351
// Send alert to monitoring system
352
sendQuotaAlert(apiPath, usagePercent, quota);
353
}
354
}
355
356
} catch (WxErrorException e) {
357
logger.error("Quota monitoring failed: {}", e.getMessage(), e);
358
}
359
}
360
361
private void sendQuotaAlert(String apiPath, long usagePercent, WxOpenMaQuotaGetResult quota) {
362
// Implementation for sending alerts (email, SMS, etc.)
363
}
364
}
365
```
366
367
### JSAPI Configuration
368
369
```java
370
@RestController
371
public class JsapiController {
372
373
@Autowired
374
private WxMaService wxMaService;
375
376
@GetMapping("/jsapi/config")
377
public Map<String, Object> getJsapiConfig(@RequestParam String url) {
378
try {
379
WxMaJsapiService jsapiService = wxMaService.getJsapiService();
380
WxJsapiSignature signature = jsapiService.createJsapiSignature(url);
381
382
Map<String, Object> config = new HashMap<>();
383
config.put("appId", wxMaService.getWxMaConfig().getAppid());
384
config.put("timestamp", signature.getTimestamp());
385
config.put("nonceStr", signature.getNonceStr());
386
config.put("signature", signature.getSignature());
387
388
return config;
389
390
} catch (WxErrorException e) {
391
logger.error("JSAPI config generation failed: {}", e.getMessage(), e);
392
throw new RuntimeException("JSAPI config generation failed", e);
393
}
394
}
395
}
396
```
397
398
This development tools module provides comprehensive support for the complete mini program development lifecycle, from code deployment to API management and monitoring.