mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-06-28 13:16:19 +08:00
🐛 修复公众号和小程序的OCR相关接口请求方式为post
This commit is contained in:
parent
fbe2dd9268
commit
6a27b838b6
@ -43,7 +43,7 @@ public class WxMaOcrServiceImpl implements WxOcrService {
|
|||||||
// ignore cannot happen
|
// ignore cannot happen
|
||||||
}
|
}
|
||||||
|
|
||||||
final String result = this.mainService.get(String.format(IDCARD, imgUrl), null);
|
final String result = this.mainService.post(String.format(IDCARD, imgUrl), null);
|
||||||
return WxOcrIdCardResult.fromJson(result);
|
return WxOcrIdCardResult.fromJson(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ public class WxMaOcrServiceImpl implements WxOcrService {
|
|||||||
// ignore cannot happen
|
// ignore cannot happen
|
||||||
}
|
}
|
||||||
|
|
||||||
final String result = this.mainService.get(String.format(BANK_CARD, imgUrl), null);
|
final String result = this.mainService.post(String.format(BANK_CARD, imgUrl), null);
|
||||||
return WxOcrBankCardResult.fromJson(result);
|
return WxOcrBankCardResult.fromJson(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ public class WxMaOcrServiceImpl implements WxOcrService {
|
|||||||
// ignore cannot happen
|
// ignore cannot happen
|
||||||
}
|
}
|
||||||
|
|
||||||
final String result = this.mainService.get(String.format(DRIVING, imgUrl), null);
|
final String result = this.mainService.post(String.format(DRIVING, imgUrl), null);
|
||||||
return WxOcrDrivingResult.fromJson(result);
|
return WxOcrDrivingResult.fromJson(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ public class WxMaOcrServiceImpl implements WxOcrService {
|
|||||||
// ignore cannot happen
|
// ignore cannot happen
|
||||||
}
|
}
|
||||||
|
|
||||||
final String result = this.mainService.get(String.format(DRIVING_LICENSE, imgUrl), null);
|
final String result = this.mainService.post(String.format(DRIVING_LICENSE, imgUrl), null);
|
||||||
return WxOcrDrivingLicenseResult.fromJson(result);
|
return WxOcrDrivingLicenseResult.fromJson(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ public class WxMaOcrServiceImpl implements WxOcrService {
|
|||||||
// ignore cannot happen
|
// ignore cannot happen
|
||||||
}
|
}
|
||||||
|
|
||||||
final String result = this.mainService.get(String.format(BIZ_LICENSE, imgUrl), null);
|
final String result = this.mainService.post(String.format(BIZ_LICENSE, imgUrl), null);
|
||||||
return WxOcrBizLicenseResult.fromJson(result);
|
return WxOcrBizLicenseResult.fromJson(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ public class WxMaOcrServiceImpl implements WxOcrService {
|
|||||||
// ignore cannot happen
|
// ignore cannot happen
|
||||||
}
|
}
|
||||||
|
|
||||||
final String result = this.mainService.get(String.format(COMM, imgUrl), null);
|
final String result = this.mainService.post(String.format(COMM, imgUrl), null);
|
||||||
return WxOcrCommResult.fromJson(result);
|
return WxOcrCommResult.fromJson(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class WxMpOcrServiceImpl implements WxOcrService {
|
|||||||
// ignore cannot happen
|
// ignore cannot happen
|
||||||
}
|
}
|
||||||
|
|
||||||
final String result = this.mainService.get(String.format(IDCARD.getUrl(this.mainService.getWxMpConfigStorage()),
|
final String result = this.mainService.post(String.format(IDCARD.getUrl(this.mainService.getWxMpConfigStorage()),
|
||||||
imgUrl), null);
|
imgUrl), null);
|
||||||
return WxOcrIdCardResult.fromJson(result);
|
return WxOcrIdCardResult.fromJson(result);
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ public class WxMpOcrServiceImpl implements WxOcrService {
|
|||||||
// ignore cannot happen
|
// ignore cannot happen
|
||||||
}
|
}
|
||||||
|
|
||||||
final String result = this.mainService.get(String.format(BANK_CARD.getUrl(this.mainService.getWxMpConfigStorage()),
|
final String result = this.mainService.post(String.format(BANK_CARD.getUrl(this.mainService.getWxMpConfigStorage()),
|
||||||
imgUrl), null);
|
imgUrl), null);
|
||||||
return WxOcrBankCardResult.fromJson(result);
|
return WxOcrBankCardResult.fromJson(result);
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ public class WxMpOcrServiceImpl implements WxOcrService {
|
|||||||
// ignore cannot happen
|
// ignore cannot happen
|
||||||
}
|
}
|
||||||
|
|
||||||
final String result = this.mainService.get(String.format(DRIVING.getUrl(this.mainService.getWxMpConfigStorage()),
|
final String result = this.mainService.post(String.format(DRIVING.getUrl(this.mainService.getWxMpConfigStorage()),
|
||||||
imgUrl), null);
|
imgUrl), null);
|
||||||
return WxOcrDrivingResult.fromJson(result);
|
return WxOcrDrivingResult.fromJson(result);
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ public class WxMpOcrServiceImpl implements WxOcrService {
|
|||||||
// ignore cannot happen
|
// ignore cannot happen
|
||||||
}
|
}
|
||||||
|
|
||||||
final String result = this.mainService.get(String.format(DRIVING_LICENSE.getUrl(this.mainService.getWxMpConfigStorage()),
|
final String result = this.mainService.post(String.format(DRIVING_LICENSE.getUrl(this.mainService.getWxMpConfigStorage()),
|
||||||
imgUrl), null);
|
imgUrl), null);
|
||||||
return WxOcrDrivingLicenseResult.fromJson(result);
|
return WxOcrDrivingLicenseResult.fromJson(result);
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ public class WxMpOcrServiceImpl implements WxOcrService {
|
|||||||
// ignore cannot happen
|
// ignore cannot happen
|
||||||
}
|
}
|
||||||
|
|
||||||
final String result = this.mainService.get(String.format(BIZ_LICENSE.getUrl(this.mainService.getWxMpConfigStorage()),
|
final String result = this.mainService.post(String.format(BIZ_LICENSE.getUrl(this.mainService.getWxMpConfigStorage()),
|
||||||
imgUrl), null);
|
imgUrl), null);
|
||||||
return WxOcrBizLicenseResult.fromJson(result);
|
return WxOcrBizLicenseResult.fromJson(result);
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ public class WxMpOcrServiceImpl implements WxOcrService {
|
|||||||
// ignore cannot happen
|
// ignore cannot happen
|
||||||
}
|
}
|
||||||
|
|
||||||
final String result = this.mainService.get(String.format(COMM.getUrl(this.mainService.getWxMpConfigStorage()),
|
final String result = this.mainService.post(String.format(COMM.getUrl(this.mainService.getWxMpConfigStorage()),
|
||||||
imgUrl), null);
|
imgUrl), null);
|
||||||
return WxOcrCommResult.fromJson(result);
|
return WxOcrCommResult.fromJson(result);
|
||||||
}
|
}
|
||||||
|
@ -153,13 +153,13 @@ public class WxMpOcrServiceImplTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class MockTest {
|
public static class MockTest {
|
||||||
private WxMpService wxService = mock(WxMpService.class);
|
private final WxMpService wxService = mock(WxMpService.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIdCard() throws Exception {
|
public void testIdCard() throws Exception {
|
||||||
String returnJson = "{\"type\":\"Back\",\"name\":\"张三\",\"id\":\"110101199909090099\",\"valid_date\":\"20110101-20210201\"}";
|
String returnJson = "{\"type\":\"Back\",\"name\":\"张三\",\"id\":\"110101199909090099\",\"valid_date\":\"20110101-20210201\"}";
|
||||||
|
|
||||||
when(wxService.get(anyString(), anyString())).thenReturn(returnJson);
|
when(wxService.post(anyString(), anyString())).thenReturn(returnJson);
|
||||||
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
||||||
|
|
||||||
final WxOcrIdCardResult result = wxMpOcrService.idCard("abc");
|
final WxOcrIdCardResult result = wxMpOcrService.idCard("abc");
|
||||||
@ -171,7 +171,7 @@ public class WxMpOcrServiceImplTest {
|
|||||||
public void testBankCard() throws Exception {
|
public void testBankCard() throws Exception {
|
||||||
String returnJson = "{\"number\":\"24234234345234\"}";
|
String returnJson = "{\"number\":\"24234234345234\"}";
|
||||||
|
|
||||||
when(wxService.get(anyString(), anyString())).thenReturn(returnJson);
|
when(wxService.post(anyString(), anyString())).thenReturn(returnJson);
|
||||||
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
||||||
|
|
||||||
final WxOcrBankCardResult result = wxMpOcrService.bankCard("abc");
|
final WxOcrBankCardResult result = wxMpOcrService.bankCard("abc");
|
||||||
@ -246,7 +246,7 @@ public class WxMpOcrServiceImplTest {
|
|||||||
" }\n" +
|
" }\n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
when(wxService.get(anyString(), anyString())).thenReturn(returnJson);
|
when(wxService.post(anyString(), anyString())).thenReturn(returnJson);
|
||||||
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
||||||
|
|
||||||
final WxOcrDrivingResult result = wxMpOcrService.driving("abc");
|
final WxOcrDrivingResult result = wxMpOcrService.driving("abc");
|
||||||
@ -271,7 +271,7 @@ public class WxMpOcrServiceImplTest {
|
|||||||
" \"valid_to\": \"2020-07-01\", //有效期限终止日\n" +
|
" \"valid_to\": \"2020-07-01\", //有效期限终止日\n" +
|
||||||
" \"official_seal\": \"xx市公安局公安交通管理局\" //印章文字\n" +
|
" \"official_seal\": \"xx市公安局公安交通管理局\" //印章文字\n" +
|
||||||
"}";
|
"}";
|
||||||
when(wxService.get(anyString(), anyString())).thenReturn(returnJson);
|
when(wxService.post(anyString(), anyString())).thenReturn(returnJson);
|
||||||
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
||||||
|
|
||||||
final WxOcrDrivingLicenseResult result = wxMpOcrService.drivingLicense("abc");
|
final WxOcrDrivingLicenseResult result = wxMpOcrService.drivingLicense("abc");
|
||||||
@ -321,7 +321,7 @@ public class WxMpOcrServiceImplTest {
|
|||||||
" \"h\": 728\n" +
|
" \"h\": 728\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
"}";
|
"}";
|
||||||
when(wxService.get(anyString(), anyString())).thenReturn(returnJson);
|
when(wxService.post(anyString(), anyString())).thenReturn(returnJson);
|
||||||
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
||||||
|
|
||||||
final WxOcrBizLicenseResult result = wxMpOcrService.bizLicense("abc");
|
final WxOcrBizLicenseResult result = wxMpOcrService.bizLicense("abc");
|
||||||
@ -383,7 +383,7 @@ public class WxMpOcrServiceImplTest {
|
|||||||
" \"h\": 720\n" +
|
" \"h\": 720\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
"}";
|
"}";
|
||||||
when(wxService.get(anyString(), anyString())).thenReturn(returnJson);
|
when(wxService.post(anyString(), anyString())).thenReturn(returnJson);
|
||||||
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
||||||
|
|
||||||
final WxOcrCommResult result = wxMpOcrService.comm("abc");
|
final WxOcrCommResult result = wxMpOcrService.comm("abc");
|
||||||
|
Loading…
Reference in New Issue
Block a user