1010import cn .binarywang .wx .miniapp .executor .QrcodeRequestExecutor ;
1111import lombok .RequiredArgsConstructor ;
1212import me .chanjar .weixin .common .error .WxErrorException ;
13+ import org .apache .commons .lang3 .StringUtils ;
1314
1415import java .io .File ;
1516
1617import static cn .binarywang .wx .miniapp .constant .WxMaApiUrlConstants .Qrcode .*;
18+ import static cn .binarywang .wx .miniapp .constant .WxMaConstants .DEFAULT_ENV_VERSION ;
1719
1820/**
1921 * @author <a href="https://github.com/binarywang">Binary Wang</a>
@@ -40,11 +42,12 @@ public File createQrcode(String path) throws WxErrorException {
4042 }
4143
4244 @ Override
43- public byte [] createWxaCodeBytes (String path , int width , boolean autoColor , WxMaCodeLineColor lineColor , boolean isHyaline )
44- throws WxErrorException {
45+ public byte [] createWxaCodeBytes (String path , String envVersion , int width , boolean autoColor ,
46+ WxMaCodeLineColor lineColor , boolean isHyaline ) throws WxErrorException {
4547 return this .service .execute (QrcodeBytesRequestExecutor .create (this .service .getRequestHttp ()), GET_WXACODE_URL ,
4648 WxaCode .builder ()
4749 .path (path )
50+ .envVersion (StringUtils .defaultIfEmpty (envVersion , DEFAULT_ENV_VERSION ))
4851 .width (width )
4952 .autoColor (autoColor )
5053 .lineColor (lineColor )
@@ -53,11 +56,12 @@ public byte[] createWxaCodeBytes(String path, int width, boolean autoColor, WxMa
5356 }
5457
5558 @ Override
56- public File createWxaCode (String path , int width , boolean autoColor , WxMaCodeLineColor lineColor , boolean isHyaline )
57- throws WxErrorException {
59+ public File createWxaCode (String path , String envVersion , int width , boolean autoColor , WxMaCodeLineColor lineColor ,
60+ boolean isHyaline ) throws WxErrorException {
5861 return this .service .execute (QrcodeRequestExecutor .create (this .service .getRequestHttp ()), GET_WXACODE_URL ,
5962 WxaCode .builder ()
6063 .path (path )
64+ .envVersion (StringUtils .defaultIfEmpty (envVersion , DEFAULT_ENV_VERSION ))
6165 .width (width )
6266 .autoColor (autoColor )
6367 .lineColor (lineColor )
@@ -67,7 +71,7 @@ public File createWxaCode(String path, int width, boolean autoColor, WxMaCodeLin
6771
6872 @ Override
6973 public File createWxaCode (String path , int width ) throws WxErrorException {
70- return this .createWxaCode (path , width , true , null , false );
74+ return this .createWxaCode (path , null , width , true , null , false );
7175 }
7276
7377 @ Override
@@ -76,21 +80,22 @@ public File createWxaCode(String path) throws WxErrorException {
7680 }
7781
7882 @ Override
79- public byte [] createWxaCodeUnlimitBytes (String scene , String page , boolean checkPath , String envVersion , int width , boolean autoColor ,
80- WxMaCodeLineColor lineColor , boolean isHyaline ) throws WxErrorException {
83+ public byte [] createWxaCodeUnlimitBytes (String scene , String page , boolean checkPath , String envVersion , int width ,
84+ boolean autoColor , WxMaCodeLineColor lineColor , boolean isHyaline )
85+ throws WxErrorException {
8186 return this .service .execute (QrcodeBytesRequestExecutor .create (this .service .getRequestHttp ()),
8287 GET_WXACODE_UNLIMIT_URL , this .buildWxaCodeUnlimit (scene , page , checkPath , envVersion , width , autoColor , lineColor , isHyaline ));
8388 }
8489
8590 @ Override
86- public File createWxaCodeUnlimit (String scene , String page , boolean checkPath , String envVersion , int width , boolean autoColor ,
87- WxMaCodeLineColor lineColor , boolean isHyaline ) throws WxErrorException {
91+ public File createWxaCodeUnlimit (String scene , String page , boolean checkPath , String envVersion , int width ,
92+ boolean autoColor , WxMaCodeLineColor lineColor , boolean isHyaline ) throws WxErrorException {
8893 return this .service .execute (QrcodeRequestExecutor .create (this .service .getRequestHttp ()),
8994 GET_WXACODE_UNLIMIT_URL , this .buildWxaCodeUnlimit (scene , page , checkPath , envVersion , width , autoColor , lineColor , isHyaline ));
9095 }
9196
92- private WxaCodeUnlimit buildWxaCodeUnlimit (String scene , String page , boolean checkPath , String envVersion , int width , boolean autoColor ,
93- WxMaCodeLineColor lineColor , boolean isHyaline ) {
97+ private WxaCodeUnlimit buildWxaCodeUnlimit (String scene , String page , boolean checkPath , String envVersion , int width ,
98+ boolean autoColor , WxMaCodeLineColor lineColor , boolean isHyaline ) {
9499 WxaCodeUnlimit wxaCodeUnlimit = new WxaCodeUnlimit ();
95100 wxaCodeUnlimit .setScene (scene );
96101 wxaCodeUnlimit .setPage (page );
@@ -106,7 +111,7 @@ private WxaCodeUnlimit buildWxaCodeUnlimit(String scene, String page, boolean ch
106111
107112 @ Override
108113 public File createWxaCodeUnlimit (String scene , String page ) throws WxErrorException {
109- return this .createWxaCodeUnlimit (scene , page , true , "release" , 430 , true , null , false );
114+ return this .createWxaCodeUnlimit (scene , page , true , DEFAULT_ENV_VERSION , 430 , true , null , false );
110115 }
111116
112117 @ Override
@@ -121,12 +126,12 @@ public File createQrcode(String path, String filePath) throws WxErrorException {
121126 }
122127
123128 @ Override
124- public File createWxaCode (String path , int width , String filePath , boolean autoColor , WxMaCodeLineColor lineColor ,
125- boolean isHyaline )
126- throws WxErrorException {
129+ public File createWxaCode (String path , String envVersion , int width , String filePath , boolean autoColor ,
130+ WxMaCodeLineColor lineColor , boolean isHyaline ) throws WxErrorException {
127131 return this .service .execute (QrcodeRequestExecutor .create (this .service .getRequestHttp (), filePath ), GET_WXACODE_URL ,
128132 WxaCode .builder ()
129133 .path (path )
134+ .envVersion (StringUtils .defaultIfEmpty (envVersion , DEFAULT_ENV_VERSION ))
130135 .width (width )
131136 .autoColor (autoColor )
132137 .lineColor (lineColor )
@@ -136,7 +141,7 @@ public File createWxaCode(String path, int width, String filePath, boolean autoC
136141
137142 @ Override
138143 public File createWxaCode (String path , int width , String filePath ) throws WxErrorException {
139- return this .createWxaCode (path , width , filePath , true , null , false );
144+ return this .createWxaCode (path , null , width , filePath , true , null , false );
140145 }
141146
142147 @ Override
@@ -145,15 +150,16 @@ public File createWxaCode(String path, String filePath) throws WxErrorException
145150 }
146151
147152 @ Override
148- public File createWxaCodeUnlimit (String scene , String page , String filePath , boolean checkPath , String envVersion , int width , boolean autoColor ,
149- WxMaCodeLineColor lineColor , boolean isHyaline ) throws WxErrorException {
153+ public File createWxaCodeUnlimit (String scene , String page , String filePath , boolean checkPath , String envVersion ,
154+ int width , boolean autoColor , WxMaCodeLineColor lineColor , boolean isHyaline )
155+ throws WxErrorException {
150156 return this .service .execute (QrcodeRequestExecutor .create (this .service .getRequestHttp (), filePath ),
151157 GET_WXACODE_UNLIMIT_URL , this .buildWxaCodeUnlimit (scene , page , checkPath , envVersion , width , autoColor , lineColor , isHyaline ));
152158 }
153159
154160 @ Override
155161 public File createWxaCodeUnlimit (String scene , String page , String filePath ) throws WxErrorException {
156- return this .createWxaCodeUnlimit (scene , page , filePath , true , "release" , 430 , true , null , false );
162+ return this .createWxaCodeUnlimit (scene , page , filePath , true , DEFAULT_ENV_VERSION , 430 , true , null , false );
157163 }
158164
159165}
0 commit comments