mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-11-01 03:25:35 +08:00 
			
		
		
		
	修正带参数的二维码接口相关文档注释,并加入对有效期的判断
This commit is contained in:
		| @ -7,7 +7,7 @@ import java.io.File; | ||||
|  | ||||
| /** | ||||
|  * 二维码相关操作接口 | ||||
|  * | ||||
|  * 文档地址:https://mp.weixin.qq.com/wiki?action=doc&id=mp1443433542&t=0.9274944716856435 | ||||
|  * @author Binary Wang | ||||
|  */ | ||||
| public interface WxMpQrcodeService { | ||||
| @ -15,28 +15,28 @@ public interface WxMpQrcodeService { | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 换取临时二维码ticket | ||||
|    * 详情请见: <a href="http://mp.weixin.qq.com/wiki/18/167e7d94df85d8389df6c94a7a8f78ba.html">生成带参数的二维码</a> | ||||
|    * 详情请见: <a href="https://mp.weixin.qq.com/wiki?action=doc&id=mp1443433542&t=0.9274944716856435">生成带参数的二维码</a> | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param sceneId       参数。 | ||||
|    * @param expireSeconds 过期秒数,默认60秒,最小60秒,最大1800秒 | ||||
|    * @param sceneId       场景值ID,临时二维码时为32位非0整型 | ||||
|    * @param expireSeconds 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。 | ||||
|    */ | ||||
|   WxMpQrCodeTicket qrCodeCreateTmpTicket(int sceneId, Integer expireSeconds) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 换取永久二维码ticket | ||||
|    * 详情请见: <a href="http://mp.weixin.qq.com/wiki/18/167e7d94df85d8389df6c94a7a8f78ba.html">生成带参数的二维码</a> | ||||
|    * 详情请见: <a href="https://mp.weixin.qq.com/wiki?action=doc&id=mp1443433542&t=0.9274944716856435">生成带参数的二维码</a> | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param sceneId 参数。永久二维码时最大值为100000(目前参数只支持1--100000) | ||||
|    * @param sceneId 场景值ID,最大值为100000(目前参数只支持1--100000) | ||||
|    */ | ||||
|   WxMpQrCodeTicket qrCodeCreateLastTicket(int sceneId) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 换取永久字符串二维码ticket | ||||
|    * 详情请见: <a href="http://mp.weixin.qq.com/wiki/18/167e7d94df85d8389df6c94a7a8f78ba.html">生成带参数的二维码</a> | ||||
|    * 详情请见: <a href="https://mp.weixin.qq.com/wiki?action=doc&id=mp1443433542&t=0.9274944716856435">生成带参数的二维码</a> | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param sceneStr 参数。字符串类型长度现在为1到64 | ||||
| @ -46,7 +46,7 @@ public interface WxMpQrcodeService { | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 换取二维码图片文件,jpg格式 | ||||
|    * 详情请见: <a href="http://mp.weixin.qq.com/wiki/18/167e7d94df85d8389df6c94a7a8f78ba.html">生成带参数的二维码</a> | ||||
|    * 详情请见: <a href="https://mp.weixin.qq.com/wiki?action=doc&id=mp1443433542&t=0.9274944716856435">生成带参数的二维码</a> | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param ticket 二维码ticket | ||||
| @ -56,7 +56,7 @@ public interface WxMpQrcodeService { | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 换取二维码图片url地址(可以选择是否生成压缩的网址) | ||||
|    * 详情请见: <a href="http://mp.weixin.qq.com/wiki/18/167e7d94df85d8389df6c94a7a8f78ba.html">生成带参数的二维码</a> | ||||
|    * 详情请见: <a href="https://mp.weixin.qq.com/wiki?action=doc&id=mp1443433542&t=0.9274944716856435">生成带参数的二维码</a> | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param ticket       二维码ticket | ||||
| @ -67,7 +67,7 @@ public interface WxMpQrcodeService { | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 换取二维码图片url地址 | ||||
|    * 详情请见: <a href="http://mp.weixin.qq.com/wiki/18/167e7d94df85d8389df6c94a7a8f78ba.html">生成带参数的二维码</a> | ||||
|    * 详情请见: <a href="https://mp.weixin.qq.com/wiki?action=doc&id=mp1443433542&t=0.9274944716856435">生成带参数的二维码</a> | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param ticket 二维码ticket | ||||
|  | ||||
| @ -28,7 +28,17 @@ public class WxMpQrcodeServiceImpl implements WxMpQrcodeService { | ||||
|   @Override | ||||
|   public WxMpQrCodeTicket qrCodeCreateTmpTicket(int sceneId, Integer expireSeconds) throws WxErrorException { | ||||
|     if (sceneId == 0) { | ||||
|       throw new WxErrorException(WxError.newBuilder().setErrorCode(-1).setErrorMsg("临时二维码场景只不能为0!").build()); | ||||
|       throw new WxErrorException(WxError.newBuilder().setErrorCode(-1).setErrorMsg("临时二维码场景值不能为0!").build()); | ||||
|     } | ||||
|  | ||||
|     //expireSeconds 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。 | ||||
|     if (expireSeconds != null && expireSeconds > 2592000) { | ||||
|       throw new WxErrorException(WxError.newBuilder().setErrorCode(-1) | ||||
|         .setErrorMsg("临时二维码有效时间最大不能超过2592000(即30天)!").build()); | ||||
|     } | ||||
|  | ||||
|     if (expireSeconds == null) { | ||||
|       expireSeconds = 30; | ||||
|     } | ||||
|  | ||||
|     String url = API_URL_PREFIX + "/create"; | ||||
|  | ||||
| @ -19,7 +19,7 @@ import java.io.File; | ||||
|  */ | ||||
| @Test(groups = "qrCodeAPI") | ||||
| @Guice(modules = ApiTestModule.class) | ||||
| public class WxMpQrCodeServiceImplTest { | ||||
| public class WxMpQrcodeServiceImplTest { | ||||
|   @Inject | ||||
|   protected WxMpService wxService; | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Binary Wang
					Binary Wang