repo
stringclasses
1k values
file_url
stringlengths
96
373
file_path
stringlengths
11
294
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
6 values
commit_sha
stringclasses
1k values
retrieved_at
stringdate
2026-01-04 14:45:56
2026-01-04 18:30:23
truncated
bool
2 classes
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopUploadCerficatesRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopUploadCerficatesRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import java.io.Serializable; import java.util.List; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; /** * @author leiin * created on 2022/6/28 11:39 上午 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaShopUploadCerficatesRequest implements Serializable { @SerializedName("out_aftersale_id") private String outAftersaleId; @SerializedName("aftersale_id") private Long aftersaleId; @SerializedName("refund_desc") private String refundDesc; @SerializedName("certificates") private List<String> certificates; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleUploadReturnInfoRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleUploadReturnInfoRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import java.io.Serializable; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; /** * @author leiin * created on 2022/6/28 11:39 上午 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaShopAfterSaleUploadReturnInfoRequest implements Serializable { @SerializedName("out_aftersale_id") private String outAftersaleId; @SerializedName("aftersale_id") private Long aftersaleId; @SerializedName("openid") private String openid; @SerializedName("delivery_id") private String deliveryId; @SerializedName("waybill_id") private String waybillId; @SerializedName("delivery_name") private String deliveryName; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopEcAfterSaleUpdateRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopEcAfterSaleUpdateRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.List; /** * @author liming1019 * created on 2022/8/26 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaShopEcAfterSaleUpdateRequest implements Serializable { private static final long serialVersionUID = 349486861004919697L; @SerializedName("out_aftersale_id") private String outAftersaleId; @SerializedName("aftersale_id") private String aftersaleId; @SerializedName("openid") private String openid; @SerializedName("type") private int type; @SerializedName("orderamt") private int orderamt; @SerializedName("refund_reason") private String refundReason; @SerializedName("refund_reason_type") private int refundReasonType; @SerializedName("media_list") private List<MediaListBean> mediaList; @Data @Builder @NoArgsConstructor @AllArgsConstructor public static class MediaListBean implements Serializable { @SerializedName("type") private int type; @SerializedName("url") private String url; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopOrderPayRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopOrderPayRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import java.io.Serializable; import lombok.Data; /** * @author leiin * created on 2021/3/23 */ @Data public class WxMaShopOrderPayRequest implements Serializable { private static final long serialVersionUID = -954667936670521398L; /** * 订单ID * <pre> * 是否必填:否 * </pre> */ @SerializedName("order_id") private Long orderId; /** * 商家自定义订单ID,与 order_id 二选一 * <pre> * 是否必填:否 * </pre> */ @SerializedName("out_order_id") private String outOrderId; /** * 用户的openid * <pre> * 是否必填:是 * </pre> */ @SerializedName("openid") private String openid; /** * 类型,默认1:支付成功,2:支付失败,3:用户取消,4:超时未支付;5:商家取消 * <pre> * 是否必填:是 * </pre> */ @SerializedName("action_type") private Integer actionType; /** * 其他具体原因 * <pre> * 是否必填:否 * </pre> */ @SerializedName("action_remark") private String actionRemark; /** * 支付订单号,action_type=1时必填 * <pre> * 是否必填:否 * </pre> */ @SerializedName("transaction_id") private String transactionId; /** * 支付完成时间,action_type=1时必填 * <pre> * 是否必填:否 * </pre> */ @SerializedName("pay_time") private String payTime; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleAddRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleAddRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * @author liming1019 * created on 2021/8/12 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaShopAfterSaleAddRequest implements Serializable { private static final long serialVersionUID = 6652525413062887786L; /** * out_order_id : xxxxx * out_aftersale_id : xxxxxx * openid : oTVP50O53a7jgmawAmxKukNlq3XI * type : 1 * create_time : 2020-12-01 00:00:00 * status : 1 * finish_all_aftersale : 0 * path : /pages/aftersale.html?out_aftersale_id=xxxxx * refund : 100 * product_infos : [{"out_product_id":"234245","out_sku_id":"23424","product_cnt":5}] */ @SerializedName("order_id") private Long orderId; @SerializedName("out_order_id") private String outOrderId; @SerializedName("out_aftersale_id") private String outAftersaleId; @SerializedName("openid") private String openid; @SerializedName("type") private Integer type; @SerializedName("product_info") private ProductInfosBean productInfo; @SerializedName("orderamt") private Long orderamt; @SerializedName("refund_reason") private String refundReason; @SerializedName("refund_reason_type") private Integer refundReasonType; @SerializedName("status") private Integer status; @SerializedName("finish_all_aftersale") private Integer finishAllAftersale; @SerializedName("path") private String path; @SerializedName("refund") private Long refund; @SerializedName("media_list") private UploadMediaList mediaList; @Data @Builder @NoArgsConstructor @AllArgsConstructor public static class ProductInfosBean implements Serializable { /** * out_product_id : 234245 * out_sku_id : 23424 * product_cnt : 5 */ @SerializedName("out_product_id") private String outProductId; @SerializedName("out_sku_id") private String outSkuId; @SerializedName("product_cnt") private Integer productCnt; } @Data public static class UploadMediaList { private Integer type; private String url; @SerializedName("thumb_url") private String thumbUrl; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliverySendRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliverySendRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import cn.binarywang.wx.miniapp.bean.shop.request.WxMaShopAfterSaleAddRequest.ProductInfosBean; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.List; /** * @author liming1019 * created on 2021/8/12 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaShopDeliverySendRequest implements Serializable { private static final long serialVersionUID = -4034672301224469057L; /** * order_id : 123456 * out_order_id : xxxxx * openid : oTVP50O53a7jgmawAmxKukNlq3XI * finish_all_delivery : 0 * delivery_list : [{"delivery_id":"SF","waybill_id":"23424324253"}] */ @SerializedName("order_id") private Long orderId; @SerializedName("out_order_id") private String outOrderId; @SerializedName("openid") private String openid; @SerializedName("finish_all_delivery") private Integer finishAllDelivery; @SerializedName("delivery_list") private List<DeliveryListBean> deliveryList; @SerializedName("ship_done_time") private String shipDoneTme; @Data @Builder @NoArgsConstructor @AllArgsConstructor public static class DeliveryListBean implements Serializable { /** * delivery_id : SF * waybill_id : 23424324253 */ @SerializedName("delivery_id") private String deliveryId; @SerializedName("waybill_id") private String waybillId; @SerializedName("product_info_list") private List<ProductInfosBean> productInfoList; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopEcAfterSaleGetRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopEcAfterSaleGetRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * @author liming1019 * created on 2022/8/25 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaShopEcAfterSaleGetRequest implements Serializable { private static final long serialVersionUID = -1967384908983649001L; @SerializedName("aftersale_id") private Long aftersaleId; @SerializedName("out_aftersale_id") private String outAftersaleId; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAccountUpdateInfoRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAccountUpdateInfoRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import lombok.Data; import java.io.Serializable; /** * @author liming1019 * created on 2021/8/9 */ @Data public class WxMaShopAccountUpdateInfoRequest implements Serializable { private static final long serialVersionUID = 5185978220275730559L; /** * 小程序path */ @SerializedName("service_agent_path") private String serviceAgentPath; /** * 小程序path */ @SerializedName("service_agent_phone") private String serviceAgentPhone; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleListRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleListRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import java.io.Serializable; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; /** * @author leiin * created on 2022/6/28 11:39 上午 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaShopAfterSaleListRequest implements Serializable { @SerializedName("status") private Integer status; //售后单状态,见 AfterSalesState @SerializedName("out_order_id") private String outOrderId; //售后单关联的外部订单号 @SerializedName("order_id") private Long orderId; //售后单关联的微信侧订单号 @SerializedName("openid") private String openid; //买家openid @SerializedName("begin_create_time") private Long beginCreateTime; //申请时间(单位毫秒)起始 @SerializedName("end_create_time") private Long endCreateTime; //申请时间(单位毫秒)结束 @SerializedName("offset") private Long offset; //本次拉取的起始位置(从0开始) @SerializedName("limit") private Integer limit; //本次拉取的大小(最大50) }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopRegisterFinishAccessInfoRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopRegisterFinishAccessInfoRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import lombok.Data; import java.io.Serializable; /** * @author liming1019 * created on 2021/8/6 */ @Data public class WxMaShopRegisterFinishAccessInfoRequest implements Serializable { private static final long serialVersionUID = 8679586799807671563L; /** * 6:完成spu接口,7:完成订单接口,8:完成物流接口,9:完成售后接口,10:测试完成,11:发版完成 */ @SerializedName("access_info_item") private Long accessInfoItem; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAuditCategoryRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAuditCategoryRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.List; /** * @author liming1019 * created on 2021/8/12 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaShopAuditCategoryRequest implements Serializable { private static final long serialVersionUID = -6730876344556487071L; /** * audit_req : {"license":["www.xxxxx.com"],"category_info":{"level1":7419,"level2":7439,"level3":7448,"certificate":["www.xxx.com"]}} */ @SerializedName("audit_req") private AuditReqBean auditReq; @Data @Builder @NoArgsConstructor @AllArgsConstructor public static class AuditReqBean implements Serializable { /** * license : ["www.xxxxx.com"] * category_info : {"level1":7419,"level2":7439,"level3":7448,"certificate":["www.xxx.com"]} */ @SerializedName("category_info") private CategoryInfoBean categoryInfo; @SerializedName("license") private List<String> license; @Data @Builder public static class CategoryInfoBean implements Serializable { /** * level1 : 7419 * level2 : 7439 * level3 : 7448 * certificate : ["www.xxx.com"] */ @SerializedName("level1") private Integer level1; @SerializedName("level2") private Integer level2; @SerializedName("level3") private Integer level3; @SerializedName("certificate") private List<String> certificate; } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliveryRecieveRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopDeliveryRecieveRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * @author liming1019 * created on 2021/8/12 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaShopDeliveryRecieveRequest implements Serializable { private static final long serialVersionUID = 1540854758624081221L; /** * order_id : 123456 * out_order_id : xxxxx * openid : oTVP50O53a7jgmawAmxKukNlq3XI */ @SerializedName("order_id") private Long orderId; @SerializedName("out_order_id") private String outOrderId; @SerializedName("openid") private String openid; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAcceptReturnRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAcceptReturnRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import java.io.Serializable; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; /** * @author leiin * created on 2022/6/28 11:39 上午 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaShopAcceptReturnRequest implements Serializable { @SerializedName("out_aftersale_id") private String outAftersaleId; @SerializedName("aftersale_id") private Long aftersaleId; @SerializedName("address_info") private RefundAddressInfo addressInfo; @Data public static class RefundAddressInfo { @SerializedName("receiver_name") private String receiverName; @SerializedName("detailed_address") private String detailedAddress; @SerializedName("tel_number") private String telNumber; @SerializedName("country") private String country; @SerializedName("province") private String province; @SerializedName("city") private String city; @SerializedName("town") private String town; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleGetRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleGetRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * @author liming1019 * created on 2021/8/12 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaShopAfterSaleGetRequest implements Serializable { private static final long serialVersionUID = -1275475147400719521L; /** * order_id : 32434234 * out_order_id : xxxxx * openid : oTVP50O53a7jgmawAmxKukNlq3XI */ @SerializedName("order_id") private Long orderId; @SerializedName("out_order_id") private String outOrderId; @SerializedName("openid") private String openid; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopPayOrderRefundRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopPayOrderRefundRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * @author liming1019 * created on 2022/8/31 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaShopPayOrderRefundRequest implements Serializable { private static final long serialVersionUID = -5850024411710741165L; @SerializedName("openid") private String openid; @SerializedName("mchid") private String mchid; @SerializedName("trade_no") private String tradeNo; @SerializedName("transaction_id") private String transactionId; @SerializedName("refund_no") private String refundNo; @SerializedName("total_amount") private int totalAmount; @SerializedName("refund_amount") private int refundAmount; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopRegisterApplySceneRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopRegisterApplySceneRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import lombok.Data; import java.io.Serializable; /** * @author liming1019 * created on 2021/8/6 */ @Data public class WxMaShopRegisterApplySceneRequest implements Serializable { private static final long serialVersionUID = -3008686013597621522L; /** * 1:视频号、公众号场景 */ @SerializedName("scene_group_id") private Long sceneGroupId; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAuditBrandRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAuditBrandRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.List; /** * @author liming1019 * created on 2021/8/12 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaShopAuditBrandRequest implements Serializable { private static final long serialVersionUID = -969331692973992066L; /** * audit_req : {"license":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"brand_info":{"brand_audit_type":1,"trademark_type":"29","brand_management_type":2,"commodity_origin_type":2,"brand_wording":"346225226351203275","sale_authorization":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_registration_certificate":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_change_certificate":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_registrant":"https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg","trademark_registrant_nu":"1249305","trademark_authorization_period":"2020-03-25 12:05:25","trademark_registration_application":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_applicant":"张三","trademark_application_time":"2020-03-25 12:05:25","imported_goods_form":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"]}} */ @SerializedName("audit_req") private AuditReqBean auditReq; @Data @Builder @NoArgsConstructor @AllArgsConstructor public static class AuditReqBean implements Serializable { /** * license : ["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"] * brand_info : {"brand_audit_type":1,"trademark_type":"29","brand_management_type":2,"commodity_origin_type":2,"brand_wording":"346225226351203275","sale_authorization":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_registration_certificate":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_change_certificate":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_registrant":"https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg","trademark_registrant_nu":"1249305","trademark_authorization_period":"2020-03-25 12:05:25","trademark_registration_application":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"],"trademark_applicant":"张三","trademark_application_time":"2020-03-25 12:05:25","imported_goods_form":["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"]} */ @SerializedName("brand_info") private BrandInfoBean brandInfo; @SerializedName("license") private List<String> license; @Data @Builder @NoArgsConstructor @AllArgsConstructor public static class BrandInfoBean implements Serializable { /** * brand_audit_type : 1 * trademark_type : 29 * brand_management_type : 2 * commodity_origin_type : 2 * brand_wording : 346225226351203275 * sale_authorization : ["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"] * trademark_registration_certificate : ["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"] * trademark_change_certificate : ["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"] * trademark_registrant : https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg * trademark_registrant_nu : 1249305 * trademark_authorization_period : 2020-03-25 12:05:25 * trademark_registration_application : ["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"] * trademark_applicant : 张三 * trademark_application_time : 2020-03-25 12:05:25 * imported_goods_form : ["https://img.zhls.qq.com/3/609b98f7e0ff43d59ce6d9cca636c3e0.jpg"] */ @SerializedName("brand_audit_type") private Integer brandAuditType; @SerializedName("trademark_type") private String trademarkType; @SerializedName("brand_management_type") private Integer brandManagementType; @SerializedName("commodity_origin_type") private Integer commodityOriginType; @SerializedName("brand_wording") private String brandWording; @SerializedName("trademark_registrant") private String trademarkRegistrant; @SerializedName("trademark_registrant_nu") private String trademarkRegistrantNu; @SerializedName("trademark_authorization_period") private String trademarkAuthorizationPeriod; @SerializedName("trademark_applicant") private String trademarkApplicant; @SerializedName("trademark_application_time") private String trademarkApplicationTime; @SerializedName("sale_authorization") private List<String> saleAuthorization; @SerializedName("trademark_registration_certificate") private List<String> trademarkRegistrationCertificate; @SerializedName("trademark_change_certificate") private List<String> trademarkChangeCertificate; @SerializedName("trademark_registration_application") private List<String> trademarkRegistrationApplication; @SerializedName("imported_goods_form") private List<String> importedGoodsForm; } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaOrderShippingIsTradeManagedRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaOrderShippingIsTradeManagedRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * @author xzh * created on 2023/5/17 17:01 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaOrderShippingIsTradeManagedRequest implements Serializable { private static final long serialVersionUID = -5735132900385013330L; /** * 必填 * 待查询小程序的 appid,非服务商调用时仅能查询本账号 */ @SerializedName("appid") private String appId; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopPayCreateOrderRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopPayCreateOrderRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.List; /** * @author liming1019 * created on 2022/8/10 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaShopPayCreateOrderRequest implements Serializable { private static final long serialVersionUID = -5597409427574429095L; @SerializedName("openid") private String openid; @SerializedName("combine_trade_no") private String combineTradeNo; @SerializedName("expire_time") private Long expireTime; @SerializedName("sub_orders") private List<SubOrdersDTO> subOrders; @NoArgsConstructor @AllArgsConstructor @Data @Builder public static class SubOrdersDTO { @SerializedName("mchid") private String mchid; @SerializedName("amount") private Integer amount; @SerializedName("trade_no") private String tradeNo; @SerializedName("description") private String description; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleUpdateRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopAfterSaleUpdateRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * @author liming1019 * created on 2021/8/12 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaShopAfterSaleUpdateRequest implements Serializable { private static final long serialVersionUID = 2712027510252221370L; /** * out_order_id : xxxxx * openid : oTVP50O53a7jgmawAmxKukNlq3XI * out_aftersale_id : xxxxxx * status : 1 * finish_all_aftersale : 0 */ @SerializedName("out_order_id") private String outOrderId; @SerializedName("openid") private String openid; @SerializedName("out_aftersale_id") private String outAftersaleId; @SerializedName("status") private Integer status; @SerializedName("finish_all_aftersale") private Integer finishAllAftersale; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopSpuPageRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/WxMaShopSpuPageRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request; import com.google.gson.annotations.SerializedName; import lombok.Data; import java.io.Serializable; /** * @author leiin * created on 2021/3/23 * spu分页参数 */ @Data public class WxMaShopSpuPageRequest implements Serializable { private static final long serialVersionUID = -4927300283039328661L; /** * 商品状态 * <pre> * 是否必填:是 * </pre> */ @SerializedName("status") private Integer status; /** * 开始创建时间 * <pre> * 是否必填:否 * </pre> */ @SerializedName("start_create_time") private String startCreateTime; /** * 结束创建时间 * <pre> * 是否必填:否 * </pre> */ @SerializedName("end_create_time") private String endCreateTime; /** * 开始更新时间 * <pre> * 是否必填:否 * </pre> */ @SerializedName("start_update_time") private String startUpdateTime; /** * 结束更新时间 * <pre> * 是否必填:否 * </pre> */ @SerializedName("end_update_time") private String endUpdateTime; /** * 默认0:获取线上数据, 1:获取草稿数据 * <pre> * 是否必填:否 * </pre> */ @SerializedName("need_edit_spu") private Integer needEditSpu; /** * 页号 * <pre> * 是否必填:是 * </pre> */ @SerializedName("page") private Integer page; /** * 页面大小 * <pre> * 是否必填:是 * </pre> */ @SerializedName("page_size") private Integer pageSize; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderCombinedShippingInfoUploadRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderCombinedShippingInfoUploadRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request.shipping; import cn.binarywang.wx.miniapp.bean.shop.request.shipping.OrderKeyBean; import cn.binarywang.wx.miniapp.bean.shop.request.shipping.PayerBean; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.List; /** * @author xzh * created on 2023/5/17 17:01 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaOrderCombinedShippingInfoUploadRequest implements Serializable { private static final long serialVersionUID = -334322216049787167L; /** * 必填 * 订单,需要上传物流信息的订单 */ @SerializedName("order_key") private OrderKeyBean orderKey; @SerializedName("sub_orders") private List<SubOrderBean> subOrders; /** * 必填 * 上传时间,用于标识请求的先后顺序 示例值: `2022-12-15T13:29:35.120+08:00 */ @SerializedName("upload_time") private String uploadTime; /** * 必填 * 支付者,支付者信息 */ @SerializedName("payer") private PayerBean payer; @Data @Builder @NoArgsConstructor @AllArgsConstructor public static class SubOrderBean implements Serializable { private static final long serialVersionUID = -8999547192454376968L; /** * 必填 * 需要上传物流详情的子单订单,订单类型与合单订单保持一致 */ @SerializedName("order_key") private OrderKeyBean orderKey; /** * 必填 * 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提 */ @SerializedName("logistics_type") private int logisticsType; /** * 必填 * 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货) * 示例值: UNIFIED_DELIVERY */ @SerializedName("delivery_mode") private int deliveryMode; /** * 分拆发货模式时必填,用于标识分拆发货模式下是否已全部发货完成,只有全部发货完成的情况下才会向用户推送发货完成通知。 * 示例值: true/false */ @SerializedName("is_all_delivered") private Boolean isAllDelivered; /** * 子单物流信息列表 多重性: [1, 10] */ @SerializedName("shipping_list") private List<ShippingListBean> shippingList; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/PayerBean.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/PayerBean.java
package cn.binarywang.wx.miniapp.bean.shop.request.shipping; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * @author xzh * @Description * @createTime 2023/07/10 10:38 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class PayerBean implements Serializable { private static final long serialVersionUID = 6628077253606871512L; /** * 必填 * 用户标识,用户在小程序appid下的唯一标识。 下单前需获取到用户的Openid 示例值: oUpF8uMuAJO_M2pxb1Q9zNjWeS6o 字符字节限制: [1, 128] */ @SerializedName("openid") private String openid; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoGetListRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoGetListRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request.shipping; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * @author xzh * created on 2023/5/17 17:01 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaOrderShippingInfoGetListRequest implements Serializable { private static final long serialVersionUID = -3682480001426075609L; /** * 支付时间所属范围 */ @SerializedName("pay_time_range") private PayTimeRange payTimeRange; /** * 订单状态枚举:(1) 待发货;(2) 已发货;(3) 确认收货;(4) 交易完成;(5) 已退款。 */ @SerializedName("order_state") private Integer orderState; /** * 支付者openid */ @SerializedName("openid") private String openId; /** * 翻页时使用,获取第一页时不用传入,如果查询结果中 has_more 字段为 true,则传入该次查询结果中返回的 last_index 字段可获取下一页。 */ @SerializedName("last_index") private String lastIndex; /** * 翻页时使用,返回列表的长度,默认为100。 */ @SerializedName("page_size") private Long pageSize; @Data public static class PayTimeRange implements Serializable { private static final long serialVersionUID = -1477231289550635468L; /** * 起始时间,时间戳形式,不填则视为从0开始 */ @SerializedName("begin_time") private Long beginTime; /** * 结束时间(含),时间戳形式,不填则视为32位无符号整型的最大值 */ @SerializedName("end_time") private Long endTime; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/ShippingListBean.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/ShippingListBean.java
package cn.binarywang.wx.miniapp.bean.shop.request.shipping; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * @author xzh * @Description * @createTime 2023/07/10 10:39 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class ShippingListBean implements Serializable { private static final long serialVersionUID = -6554762808990702774L; /** * 物流单号,物流快递发货时必填,示例值: 323244567777 字符字节限制: [1, 128] */ @SerializedName("tracking_no") private String trackingNo; /** * 物流公司编码,快递公司ID,参见「查询物流公司编码列表」,物流快递发货时必填, 示例值: DHL 字符字节限制: [1, 128] */ @SerializedName("express_company") private String expressCompany; /** * 必填 * 商品信息,例如:微信红包抱枕*1个,限120个字以内 */ @SerializedName("item_desc") private String itemDesc; /** * 联系方式,当发货的物流公司为顺丰时,联系方式为必填,收件人或寄件人联系方式二选一 */ @SerializedName("contact") private ContactBean contact; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/OrderKeyBean.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/OrderKeyBean.java
package cn.binarywang.wx.miniapp.bean.shop.request.shipping; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * @author xzh * @Description * @createTime 2023/07/10 10:37 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class OrderKeyBean implements Serializable { private static final long serialVersionUID = -6322907878214196106L; /** * 必填 * 订单单号类型,用于确认需要上传详情的订单。枚举值1,使用下单商户号和商户侧单号;枚举值2,使用微信支付单号。 */ @SerializedName("order_number_type") private int orderNumberType; /** * 原支付交易对应的微信订单号 */ @SerializedName("transaction_id") private String transactionId; /** * 支付下单商户的商户号,由微信支付生成并下发。 */ @SerializedName("mchid") private String mchId; /** * 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一 */ @SerializedName("out_trade_no") private String outTradeNo; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoNotifyConfirmRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoNotifyConfirmRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request.shipping; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * @author xzh * created on 2023/5/17 17:01 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaOrderShippingInfoNotifyConfirmRequest implements Serializable { private static final long serialVersionUID = -6868378515860675152L; /** * 原支付交易对应的微信订单号 */ @SerializedName("transaction_id") private String transactionId; /** * 支付下单商户的商户号,由微信支付生成并下发 */ @SerializedName("merchant_id") private String merchantId; /** * 二级商户号 */ @SerializedName("sub_merchant_id") private String subMerchantId; /** * 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一。 */ @SerializedName("merchant_trade_no") private String merchantTradeNo; /** * 快递签收时间,时间戳形式。 */ @SerializedName("received_time") private Long receivedTime; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoUploadRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoUploadRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request.shipping; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.List; /** * @author xzh * created on 2023/5/17 17:01 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaOrderShippingInfoUploadRequest implements Serializable { private static final long serialVersionUID = -334322216049787167L; /** * 必填 * 订单,需要上传物流信息的订单 */ @SerializedName("order_key") private OrderKeyBean orderKey; /** * 必填 * 物流模式,发货方式枚举值:1、实体物流配送采用快递公司进行实体物流配送形式 2、同城配送 3、虚拟商品,虚拟商品,例如话费充值,点卡等,无实体配送形式 4、用户自提 */ @SerializedName("logistics_type") private int logisticsType; /** * 必填 * 发货模式,发货模式枚举值:1、UNIFIED_DELIVERY(统一发货)2、SPLIT_DELIVERY(分拆发货) * 示例值: UNIFIED_DELIVERY */ @SerializedName("delivery_mode") private int deliveryMode; /** * 分拆发货模式时必填,用于标识分拆发货模式下是否已全部发货完成,只有全部发货完成的情况下才会向用户推送发货完成通知。 * 示例值: true/false */ @SerializedName("is_all_delivered") private Boolean isAllDelivered; /** * 必填 * 物流信息列表,发货物流单列表,支持统一发货(单个物流单)和分拆发货(多个物流单)两种模式,多重性: [1, 10] */ @SerializedName("shipping_list") private List<ShippingListBean> shippingList; /** * 必填 * 上传时间,用于标识请求的先后顺序 示例值: `2022-12-15T13:29:35.120+08:00 */ @SerializedName("upload_time") private String uploadTime; /** * 必填 * 支付者,支付者信息 */ @SerializedName("payer") private PayerBean payer; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/ContactBean.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/ContactBean.java
package cn.binarywang.wx.miniapp.bean.shop.request.shipping; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * @author xzh * @Description * @createTime 2023/07/10 10:38 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class ContactBean implements Serializable { private static final long serialVersionUID = 3388264169113920140L; /** * 寄件人联系方式,寄件人联系方式,采用掩码传输,最后4位数字不能打掩码 示例值: `189****1234, 021-****1234, ****1234, 0**2-***1234, 0**2-******23-10, ****123-8008` 值限制: 0 ≤ value ≤ 1024 */ @SerializedName("consignor_contact") private String consignorContact; /** * 收件人联系方式,收件人联系方式为,采用掩码传输,最后4位数字不能打掩码 示例值: `189****1234, 021-****1234, ****1234, 0**2-***1234, 0**2-******23-10, ****123-8008` 值限制: 0 ≤ value ≤ 1024 */ @SerializedName("receiver_contact") private String receiverContact; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoGetRequest.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/shop/request/shipping/WxMaOrderShippingInfoGetRequest.java
package cn.binarywang.wx.miniapp.bean.shop.request.shipping; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * @author xzh * created on 2023/5/17 17:01 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMaOrderShippingInfoGetRequest implements Serializable { private static final long serialVersionUID = -6868378515860675152L; /** * 原支付交易对应的微信订单号 */ @SerializedName("transaction_id") private String transactionId; /** * 支付下单商户的商户号,由微信支付生成并下发 */ @SerializedName("merchant_id") private String merchantId; /** * 二级商户号 */ @SerializedName("sub_merchant_id") private String subMerchantId; /** * 商户系统内部订单号,只能是数字、大小写字母`_-*`且在同一个商户号下唯一。 */ @SerializedName("merchant_trade_no") private String merchantTradeNo; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageHandler.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageHandler.java
package cn.binarywang.wx.miniapp.message; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaMessage; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.session.WxSessionManager; import java.util.Map; /** * 处理小程序推送消息的处理器接口. * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public interface WxMaMessageHandler { /** * 处理消息. * * @param message 输入消息 * @param context 上下文 * @param service 服务类 * @param sessionManager session管理器 * @return 输出消息,可以是XML格式或JSON格式 * @throws WxErrorException 异常 */ WxMaOutMessage handle(WxMaMessage message, Map<String, Object> context, WxMaService service, WxSessionManager sessionManager) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaOutMessage.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaOutMessage.java
package cn.binarywang.wx.miniapp.message; import cn.binarywang.wx.miniapp.config.WxMaConfig; import java.io.Serializable; /** * 微信小程序输出消息的通用接口,支持XML和JSON两种格式. * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public interface WxMaOutMessage extends Serializable { /** * 转换成XML格式. * * @return XML格式的消息 */ String toXml(); /** * 转换成JSON格式. * * @return JSON格式的消息 */ String toJson(); /** * 转换成加密的XML格式. * * @param config 配置对象 * @return 加密后的XML格式消息 */ String toEncryptedXml(WxMaConfig config); /** * 转换成加密的JSON格式. * * @param config 配置对象 * @return 加密后的JSON格式消息 */ String toEncryptedJson(WxMaConfig config); }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaJsonOutMessage.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaJsonOutMessage.java
package cn.binarywang.wx.miniapp.message; import cn.binarywang.wx.miniapp.config.WxMaConfig; import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import java.io.Serializable; /** * 微信小程序输出给微信服务器的JSON格式消息. * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ @Data @Accessors(chain = true) @Builder @AllArgsConstructor @NoArgsConstructor public class WxMaJsonOutMessage implements WxMaOutMessage { private static final long serialVersionUID = 4241135225946919154L; protected String toUserName; protected String fromUserName; protected Long createTime; protected String msgType; /** * 转换成JSON格式. */ @Override public String toJson() { return WxMaGsonBuilder.create().toJson(this); } /** * 转换成XML格式(对于JSON消息类型,返回JSON格式). */ @Override public String toXml() { // JSON消息类型默认返回JSON格式 return toJson(); } /** * 转换成加密的JSON格式. */ @Override public String toEncryptedJson(WxMaConfig config) { String plainJson = toJson(); WxMaCryptUtils pc = new WxMaCryptUtils(config); return pc.encrypt(plainJson); } /** * 转换成加密的XML格式(对于JSON消息类型,返回加密的JSON格式). */ @Override public String toEncryptedXml(WxMaConfig config) { // JSON消息类型默认返回加密的JSON格式 return toEncryptedJson(config); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouterRule.java
package cn.binarywang.wx.miniapp.message; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaMessage; import me.chanjar.weixin.common.api.WxErrorExceptionHandler; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.session.WxSessionManager; import java.util.*; import java.util.regex.Pattern; /** * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public class WxMaMessageRouterRule { private final WxMaMessageRouter routerBuilder; private boolean async = true; private String fromUser; private String msgType; private String event; private String eventKey; private String content; private String rContent; private String title; private WxMaMessageMatcher matcher; private boolean reEnter = false; private List<WxMaMessageHandler> handlers = new ArrayList<>(); private List<WxMaMessageInterceptor> interceptors = new ArrayList<>(); public WxMaMessageRouterRule(WxMaMessageRouter routerBuilder) { this.routerBuilder = routerBuilder; } /** * 设置是否异步执行,默认是true. */ public WxMaMessageRouterRule async(boolean async) { this.async = async; return this; } /** * 如果msgType等于某值. */ public WxMaMessageRouterRule msgType(String msgType) { this.msgType = msgType; return this; } /** * 标题,发送小程序页卡时有效 * @param title * @return */ public WxMaMessageRouterRule title(String title){ this.title = title; return this; } /** * 如果event等于某值. */ public WxMaMessageRouterRule event(String event) { this.event = event; return this; } /** * 如果eventKey等于某值. */ public WxMaMessageRouterRule eventKey(String eventKey) { this.eventKey = eventKey; return this; } /** * 如果content等于某值. */ public WxMaMessageRouterRule content(String content) { this.content = content; return this; } /** * 如果content匹配该正则表达式. */ public WxMaMessageRouterRule rContent(String regex) { this.rContent = regex; return this; } /** * 如果fromUser等于某值. */ public WxMaMessageRouterRule fromUser(String fromUser) { this.fromUser = fromUser; return this; } /** * 如果消息匹配某个matcher,用在用户需要自定义更复杂的匹配规则的时候. */ public WxMaMessageRouterRule matcher(WxMaMessageMatcher matcher) { this.matcher = matcher; return this; } /** * 设置微信消息拦截器. */ public WxMaMessageRouterRule interceptor(WxMaMessageInterceptor interceptor) { return interceptor(interceptor, (WxMaMessageInterceptor[]) null); } /** * 设置微信消息拦截器. */ public WxMaMessageRouterRule interceptor(WxMaMessageInterceptor interceptor, WxMaMessageInterceptor... otherInterceptors) { this.interceptors.add(interceptor); if (otherInterceptors != null && otherInterceptors.length > 0) { Collections.addAll(this.interceptors, otherInterceptors); } return this; } /** * 设置微信消息处理器. */ public WxMaMessageRouterRule handler(WxMaMessageHandler handler) { return handler(handler, (WxMaMessageHandler[]) null); } /** * 设置微信消息处理器. */ public WxMaMessageRouterRule handler(WxMaMessageHandler handler, WxMaMessageHandler... otherHandlers) { this.handlers.add(handler); if (otherHandlers != null && otherHandlers.length > 0) { Collections.addAll(this.handlers, otherHandlers); } return this; } /** * 规则结束,代表如果一个消息匹配该规则,那么它将不再会进入其他规则. */ public WxMaMessageRouter end() { this.routerBuilder.getRules().add(this); return this.routerBuilder; } /** * 规则结束,但是消息还会进入其他规则. */ public WxMaMessageRouter next() { this.reEnter = true; return end(); } /** * 将微信自定义的事件修正为不区分大小写. * 比如框架定义的事件常量为click,但微信传递过来的却是CLICK */ protected boolean test(WxMaMessage wxMessage) { return (this.fromUser == null || this.fromUser.equals(wxMessage.getFromUser())) && (this.msgType == null || this.msgType.toLowerCase().equals((wxMessage.getMsgType() == null ? null : wxMessage.getMsgType().toLowerCase()))) && (this.event == null || this.event.toLowerCase().equals((wxMessage.getEvent() == null ? null : wxMessage.getEvent().toLowerCase()))) && (this.content == null || this.content .equals(wxMessage.getContent() == null ? null : wxMessage.getContent().trim())) && (this.rContent == null || Pattern .matches(this.rContent, wxMessage.getContent() == null ? "" : wxMessage.getContent().trim())) && (this.matcher == null || this.matcher.match(wxMessage)) && (this.title == null || this.title .equals(wxMessage.getTitle() == null ? null : wxMessage.getTitle().trim())) ; } /** * 处理微信推送过来的消息. */ protected WxMaOutMessage service(WxMaMessage wxMessage, Map<String, Object> context, WxMaService wxMaService, WxSessionManager sessionManager, WxErrorExceptionHandler exceptionHandler) { if (context == null) { context = new HashMap<>(16); } WxMaOutMessage outMessage = null; try { // 如果拦截器不通过 for (WxMaMessageInterceptor interceptor : this.interceptors) { if (!interceptor.intercept(wxMessage, context, wxMaService, sessionManager)) { return null; } } // 交给handler处理 for (WxMaMessageHandler handler : this.handlers) { // 返回最后handler的结果 if (handler == null) { continue; } outMessage = handler.handle(wxMessage, context, wxMaService, sessionManager); } } catch (WxErrorException e) { exceptionHandler.handle(e); } return outMessage; } public WxMaMessageRouter getRouterBuilder() { return this.routerBuilder; } public boolean isAsync() { return this.async; } public void setAsync(boolean async) { this.async = async; } public String getFromUser() { return this.fromUser; } public void setFromUser(String fromUser) { this.fromUser = fromUser; } public String getMsgType() { return this.msgType; } public void setMsgType(String msgType) { this.msgType = msgType; } public String getEvent() { return this.event; } public void setEvent(String event) { this.event = event; } public String getEventKey() { return this.eventKey; } public void setEventKey(String eventKey) { this.eventKey = eventKey; } public String getContent() { return this.content; } public void setContent(String content) { this.content = content; } public String getrContent() { return this.rContent; } public void setrContent(String rContent) { this.rContent = rContent; } public WxMaMessageMatcher getMatcher() { return this.matcher; } public void setMatcher(WxMaMessageMatcher matcher) { this.matcher = matcher; } public boolean isReEnter() { return this.reEnter; } public void setReEnter(boolean reEnter) { this.reEnter = reEnter; } public List<WxMaMessageHandler> getHandlers() { return this.handlers; } public void setHandlers(List<WxMaMessageHandler> handlers) { this.handlers = handlers; } public List<WxMaMessageInterceptor> getInterceptors() { return this.interceptors; } public void setInterceptors(List<WxMaMessageInterceptor> interceptors) { this.interceptors = interceptors; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageInterceptor.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageInterceptor.java
package cn.binarywang.wx.miniapp.message; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaMessage; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.session.WxSessionManager; import java.util.Map; /** * 微信消息拦截器,可以用来做验证. * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public interface WxMaMessageInterceptor { /** * 拦截微信消息. * * @param wxMessage . * @param context 上下文,如果handler或interceptor之间有信息要传递,可以用这个 * @param wxMaService . * @param sessionManager . * @return true代表OK,false代表不OK * @throws WxErrorException . */ boolean intercept(WxMaMessage wxMessage, Map<String, Object> context, WxMaService wxMaService, WxSessionManager sessionManager) throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageMatcher.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageMatcher.java
package cn.binarywang.wx.miniapp.message; import cn.binarywang.wx.miniapp.bean.WxMaMessage; /** * 消息匹配器,用在消息路由的时候. * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public interface WxMaMessageMatcher { /** * 消息是否匹配某种模式. * * @param message 消息 * @return 是否匹配 */ boolean match(WxMaMessage message); }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaXmlOutMessage.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaXmlOutMessage.java
package cn.binarywang.wx.miniapp.message; import cn.binarywang.wx.miniapp.config.WxMaConfig; import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; import cn.binarywang.wx.miniapp.util.xml.XStreamTransformer; import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamConverter; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; import java.io.Serializable; /** * 微信小程序输出给微信服务器的消息. * * @author <a href="https://github.com/binarywang">Binary Wang</a> * created on 2019-06-22 */ @Data @XStreamAlias("xml") @Accessors(chain = true) @Builder @AllArgsConstructor @NoArgsConstructor public class WxMaXmlOutMessage implements WxMaOutMessage { private static final long serialVersionUID = 4241135225946919153L; @XStreamAlias("ToUserName") @XStreamConverter(value = XStreamCDataConverter.class) protected String toUserName; @XStreamAlias("FromUserName") @XStreamConverter(value = XStreamCDataConverter.class) protected String fromUserName; @XStreamAlias("CreateTime") protected Long createTime; @XStreamAlias("MsgType") @XStreamConverter(value = XStreamCDataConverter.class) protected String msgType; @SuppressWarnings("unchecked") @Override public String toXml() { return XStreamTransformer.toXml((Class<WxMaXmlOutMessage>) this.getClass(), this); } /** * 转换成JSON格式(对于XML消息类型,返回XML格式). */ @Override public String toJson() { // XML消息类型默认返回XML格式 return toXml(); } /** * 转换成加密的xml格式. */ @Override public String toEncryptedXml(WxMaConfig config) { String plainXml = toXml(); WxMaCryptUtils pc = new WxMaCryptUtils(config); return pc.encrypt(plainXml); } /** * 转换成加密的JSON格式(对于XML消息类型,返回加密的XML格式). */ @Override public String toEncryptedJson(WxMaConfig config) { // XML消息类型默认返回加密的XML格式 return toEncryptedXml(config); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/message/WxMaMessageRouter.java
package cn.binarywang.wx.miniapp.message; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.bean.WxMaMessage; import cn.binarywang.wx.miniapp.util.WxMaConfigHolder; import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.Data; import me.chanjar.weixin.common.api.WxErrorExceptionHandler; import me.chanjar.weixin.common.api.WxMessageDuplicateChecker; import me.chanjar.weixin.common.api.WxMessageInMemoryDuplicateCheckerSingleton; import me.chanjar.weixin.common.session.InternalSession; import me.chanjar.weixin.common.session.InternalSessionManager; import me.chanjar.weixin.common.session.StandardSessionManager; import me.chanjar.weixin.common.session.WxSessionManager; import me.chanjar.weixin.common.util.LogExceptionHandler; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.*; /** * @author <a href="https://github.com/binarywang">Binary Wang</a> */ @Data public class WxMaMessageRouter { private static final int DEFAULT_THREAD_POOL_SIZE = 100; private final Logger log = LoggerFactory.getLogger(WxMaMessageRouter.class); private final List<WxMaMessageRouterRule> rules = new ArrayList<>(); private final WxMaService wxMaService; private ExecutorService executorService; private WxSessionManager sessionManager; private WxErrorExceptionHandler exceptionHandler; private WxMessageDuplicateChecker messageDuplicateChecker; public WxMaMessageRouter(WxMaService wxMaService) { this.wxMaService = wxMaService; ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("WxMaMessageRouter-pool-%d").build(); this.executorService = new ThreadPoolExecutor(DEFAULT_THREAD_POOL_SIZE, DEFAULT_THREAD_POOL_SIZE, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), namedThreadFactory); this.sessionManager = new StandardSessionManager(); this.exceptionHandler = new LogExceptionHandler(); this.messageDuplicateChecker = WxMessageInMemoryDuplicateCheckerSingleton.getInstance(); } /** * 使用自定义的 {@link ExecutorService}. */ public WxMaMessageRouter(WxMaService wxMaService, ExecutorService executorService) { this.wxMaService = wxMaService; this.executorService = executorService; this.sessionManager = new StandardSessionManager(); this.exceptionHandler = new LogExceptionHandler(); this.messageDuplicateChecker = WxMessageInMemoryDuplicateCheckerSingleton.getInstance(); } /** * 系统退出前,应该调用该方法 */ public void shutDownExecutorService() { this.executorService.shutdown(); } /** * 系统退出前,应该调用该方法,增加了超时时间检测 */ public void shutDownExecutorService(Integer second) { this.executorService.shutdown(); try { if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS)) { this.executorService.shutdownNow(); if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS)) log.error("线程池未关闭!"); } } catch (InterruptedException ie) { this.executorService.shutdownNow(); Thread.currentThread().interrupt(); } } /** * <pre> * 设置自定义的 {@link ExecutorService} * 如果不调用该方法,默认使用内置的 * </pre> */ public void setExecutorService(ExecutorService executorService) { this.executorService = executorService; } /** * 开始一个新的Route规则. */ public WxMaMessageRouterRule rule() { return new WxMaMessageRouterRule(this); } /** * 处理微信消息. */ public WxMaOutMessage route(final WxMaMessage wxMessage, final Map<String, Object> context) { if (isMsgDuplicated(wxMessage)) { // 如果是重复消息,那么就不做处理 return null; } final List<WxMaMessageRouterRule> matchRules = new ArrayList<>(); // 收集匹配的规则 for (final WxMaMessageRouterRule rule : this.rules) { if (rule.test(wxMessage)) { matchRules.add(rule); if (!rule.isReEnter()) { break; } } } if (matchRules.isEmpty()) { return null; } final List<Future<?>> futures = new ArrayList<>(); WxMaOutMessage result = null; for (final WxMaMessageRouterRule rule : matchRules) { // 返回最后一个非异步的rule的执行结果 if (rule.isAsync()) { //获取当前线程使用的实际appId,兼容只有一个appId,且未显式设置当前使用的appId的情况 String miniAppId = this.wxMaService.getWxMaConfig().getAppid(); futures.add( this.executorService.submit(() -> { //子线程中设置实际的appId this.wxMaService.switchoverTo(miniAppId); rule.service(wxMessage, context, WxMaMessageRouter.this.wxMaService, WxMaMessageRouter.this.sessionManager, WxMaMessageRouter.this.exceptionHandler); WxMaConfigHolder.remove(); }) ); } else { result = rule.service(wxMessage, context, this.wxMaService, this.sessionManager, this.exceptionHandler); // 在同步操作结束,session访问结束 this.log.debug("End session access: async=false, sessionId={}", wxMessage.getFromUser()); sessionEndAccess(wxMessage); } } if (!futures.isEmpty()) { this.executorService.submit(() -> { for (Future<?> future : futures) { try { future.get(); WxMaMessageRouter.this.log.debug("End session access: async=true, sessionId={}", wxMessage.getFromUser()); // 异步操作结束,session访问结束 sessionEndAccess(wxMessage); } catch (InterruptedException | ExecutionException e) { WxMaMessageRouter.this.log.error("Error happened when wait task finish", e); } } }); } return result; } public WxMaOutMessage route(final WxMaMessage wxMessage) { return this.route(wxMessage, new HashMap<>(2)); } protected boolean isMsgDuplicated(WxMaMessage wxMessage) { StringBuilder messageId = new StringBuilder(); if (wxMessage.getMsgId() == null) { messageId.append(wxMessage.getCreateTime()) .append("-").append(wxMessage.getFromUser()) .append("-").append(StringUtils.trimToEmpty(wxMessage.getEvent())); } else { messageId.append(wxMessage.getMsgId()) .append("-").append(wxMessage.getCreateTime()) .append("-").append(wxMessage.getFromUser()); } if (StringUtils.isNotEmpty(wxMessage.getToUser())) { messageId.append("-").append(wxMessage.getToUser()); } if (StringUtils.isNotEmpty(wxMessage.getTraceId())) { messageId.append("-").append(wxMessage.getTraceId()); } return this.messageDuplicateChecker.isDuplicate(messageId.toString()); } /** * 对session的访问结束. */ private void sessionEndAccess(WxMaMessage wxMessage) { InternalSession session = ((InternalSessionManager) this.sessionManager).findSession(wxMessage.getFromUser()); if (session != null) { session.endAccess(); } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/WxMaConfig.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/WxMaConfig.java
package cn.binarywang.wx.miniapp.config; import java.util.concurrent.locks.Lock; import java.util.function.Consumer; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.bean.WxAccessTokenEntity; import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; /** * 小程序配置 * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public interface WxMaConfig { default void setUpdateAccessTokenBefore(Consumer<WxAccessTokenEntity> updateAccessTokenBefore) {} /** * 获取当前的 access_token * * @return 当前的 access_token 字符串 */ String getAccessToken(); // region 稳定版access token boolean isStableAccessToken(); void useStableAccessToken(boolean useStableAccessToken); // endregion /** * 获取用于保护 access_token 更新的锁(线程安全用) * * @return access_token 的锁对象 */ Lock getAccessTokenLock(); /** * 判断 access_token 是否已过期 * * @return 如果已过期则返回 true,否则返回 false */ boolean isAccessTokenExpired(); /** * 强制将 access_token 标记为已过期 */ void expireAccessToken(); /** * 应该是线程安全的 * * @param accessToken 要更新的 WxAccessToken 对象 */ default void updateAccessToken(WxAccessToken accessToken) { updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); } /** * 应该是线程安全的 * * @param accessToken 新的 access_token 值 * @param expiresInSeconds 过期时间,单位:秒 */ void updateAccessToken(String accessToken, int expiresInSeconds); default void updateAccessTokenProcessor(String accessToken, int expiresInSeconds) { WxAccessTokenEntity wxAccessTokenEntity = new WxAccessTokenEntity(); wxAccessTokenEntity.setAppid(getAppid()); wxAccessTokenEntity.setAccessToken(accessToken); wxAccessTokenEntity.setExpiresIn(expiresInSeconds); updateAccessTokenBefore(wxAccessTokenEntity); updateAccessToken(accessToken, expiresInSeconds); } default void updateAccessTokenBefore(WxAccessTokenEntity wxAccessTokenEntity) {} /** * 获取当前的 JSAPI ticket * * @return 当前的 jsapi_ticket 字符串 */ String getJsapiTicket(); /** * 获取用于保护 jsapi_ticket 更新的锁(线程安全用) * * @return jsapi_ticket 的锁对象 */ Lock getJsapiTicketLock(); /** * 判断 jsapi_ticket 是否已过期 * * @return 如果已过期则返回 true,否则返回 false */ boolean isJsapiTicketExpired(); /** * 强制将 jsapi_ticket 标记为已过期 */ void expireJsapiTicket(); /** * 应该是线程安全的 * * @param jsapiTicket 新的 jsapi_ticket 值 * @param expiresInSeconds 过期时间,单位:秒 */ void updateJsapiTicket(String jsapiTicket, int expiresInSeconds); /** * 获取卡券相关的 api_ticket * * @return 卡券 api_ticket 字符串 */ String getCardApiTicket(); /** * 获取用于保护卡券 api_ticket 更新的锁(线程安全用) * * @return 卡券 api_ticket 的锁对象 */ Lock getCardApiTicketLock(); /** * 判断卡券 api_ticket 是否已过期 * * @return 如果已过期则返回 true,否则返回 false */ boolean isCardApiTicketExpired(); /** * 强制将卡券 api_ticket 标记为已过期 */ void expireCardApiTicket(); /** * 应该是线程安全的 * * @param apiTicket 新的卡券 api_ticket 值 * @param expiresInSeconds 过期时间,单位:秒 */ void updateCardApiTicket(String apiTicket, int expiresInSeconds); /** * 获取小程序的 appId * * @return 小程序的 appId */ String getAppid(); /** * 获取小程序的 secret * * @return 小程序的 secret */ String getSecret(); /** * 获取消息校验用的 token * * @return token 字符串 */ String getToken(); /** * 获取消息加解密使用的 AES 密钥(用于消息加密/解密) * * @return AES 密钥字符串 */ String getAesKey(); /** * 获取原始 ID(原始公众号/小程序 ID) * * @return 原始 ID 字符串 */ String getOriginalId(); /** * 获取云开发(Cloud)环境标识 * * @return 云环境 ID */ String getCloudEnv(); /** * 获取消息数据的格式(例如 json) * * @return 消息数据格式字符串 */ String getMsgDataFormat(); /** * 获取 access_token 或 ticket 的过期时间(时间戳) * * @return 过期时间的毫秒时间戳 */ long getExpiresTime(); /** * 获取 HTTP 代理主机 * * @return 代理主机名或 IP */ String getHttpProxyHost(); /** * 获取 HTTP 代理端口 * * @return 代理端口号 */ int getHttpProxyPort(); /** * 获取 HTTP 代理用户名 * * @return 代理用户名 */ String getHttpProxyUsername(); /** * 获取 HTTP 代理密码 * * @return 代理密码 */ String getHttpProxyPassword(); /** * HTTP 请求重试间隔(毫秒) * * <pre> * {@link cn.binarywang.wx.miniapp.api.impl.BaseWxMaServiceImpl#setRetrySleepMillis(int)} * </pre> * * @return 重试间隔,单位:毫秒 */ int getRetrySleepMillis(); /** * HTTP 请求最大重试次数 * * <pre> * {@link cn.binarywang.wx.miniapp.api.impl.BaseWxMaServiceImpl#setMaxRetryTimes(int)} * </pre> * * @return 最大重试次数 */ int getMaxRetryTimes(); /** * 获取用于创建 HTTP 客户端的 ApacheHttpClientBuilder * * @return ApacheHttpClientBuilder 实例 */ ApacheHttpClientBuilder getApacheHttpClientBuilder(); /** * 是否在 token 失效时自动刷新 * * @return 如果自动刷新则返回 true,否则返回 false */ boolean autoRefreshToken(); /** * 设置自定义的 apiHost 地址 * 具体取值,可以参考 <a href="https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Interface_field_description.html">API 域名文档</a> * * @param apiHostUrl api 域名地址 */ void setApiHostUrl(String apiHostUrl); /** * 获取自定义的 apiHost 地址,用于替换原请求中的 <a href="https://api.weixin.qq.com">https://api.weixin.qq.com</a> * 具体取值,可以参考 <a href="https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Interface_field_description.html">API 域名文档</a> * * @return 自定义的 api 域名地址 */ String getApiHostUrl(); /** * 获取自定义的获取 accessToken 地址,用于向自定义统一服务获取 accessToken * * @return 自定义的获取 accessToken 地址 */ String getAccessTokenUrl(); /** * 设置自定义的获取 accessToken 地址,可用于设置获取 accessToken 的自定义服务 * * @param accessTokenUrl 自定义的获取 accessToken 地址 */ void setAccessTokenUrl(String accessTokenUrl); /** * 服务端 API 签名用到的 RSA 私钥(pkcs8 格式,会以 -----BEGIN PRIVATE KEY----- 开头, * 'BEGIN RSA PRIVATE KEY' 的是 pkcs1 格式,需要转换(可用 openssl 转换)。设置参考: * <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/getting_started/api_signature.html">API 签名文档</a> * * @return RSA 私钥字符串(pkcs8 格式) */ String getApiSignatureRsaPrivateKey(); /** * 服务端 API 签名用到的 AES 密钥 * <a href="https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/getting_started/api_signature.html">API 签名文档</a> * * @return AES 密钥字符串 */ String getApiSignatureAesKey(); /** 密钥对应的序号 */ String getApiSignatureAesKeySn(); /** 密钥对应的序号 */ String getApiSignatureRsaPrivateKeySn(); /** 密钥对应的小程序 ID(普通小程序为 appId,托管第三方平台为 componentAppId) */ String getWechatMpAppid(); /** 微信 API 默认主机地址 */ String DEFAULT_API_HOST_URL = "https://api.weixin.qq.com"; /** 微信云托管使用的 HTTP 协议主机地址 */ String CLOUD_RUN_API_HOST_URL = "http://api.weixin.qq.com"; /** * 是否使用微信云托管内网模式 * 当部署在微信云托管环境时,api.weixin.qq.com 会被解析为内网地址,此时需要使用 HTTP 协议访问 * 开启此配置后,SDK 会自动将 https://api.weixin.qq.com 替换为 http://api.weixin.qq.com * * @see <a href="https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloudrun/src/guide/weixin/open.html">微信云托管内网调用微信接口</a> * @return 是否使用微信云托管模式 */ default boolean isUseWxCloudRun() { return false; } /** * 设置是否使用微信云托管内网模式 * 当部署在微信云托管环境时,api.weixin.qq.com 会被解析为内网地址,此时需要使用 HTTP 协议访问 * 开启此配置后,SDK 会自动将 https://api.weixin.qq.com 替换为 http://api.weixin.qq.com * * @see <a href="https://developers.weixin.qq.com/miniprogram/dev/wxcloudservice/wxcloudrun/src/guide/weixin/open.html">微信云托管内网调用微信接口</a> * @param useWxCloudRun 是否使用微信云托管模式 */ default void setUseWxCloudRun(boolean useWxCloudRun) { // 默认空实现 } /** * 根据配置获取实际应使用的 API 主机地址 * 优先级:自定义 apiHostUrl > 微信云托管模式 > 默认 HTTPS 地址 * * @return 实际应使用的 API 主机地址 */ default String getEffectiveApiHostUrl() { String apiHostUrl = getApiHostUrl(); if (apiHostUrl != null && !apiHostUrl.isEmpty()) { return apiHostUrl; } if (isUseWxCloudRun()) { return CLOUD_RUN_API_HOST_URL; } return DEFAULT_API_HOST_URL; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/AbstractWxMaRedisConfig.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/AbstractWxMaRedisConfig.java
package cn.binarywang.wx.miniapp.config.impl; import me.chanjar.weixin.common.error.WxRuntimeException; import redis.clients.jedis.Jedis; import redis.clients.jedis.params.SetParams; import java.io.File; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; /** * @author <a href="https://github.com/winter4666">winter</a> */ public abstract class AbstractWxMaRedisConfig extends WxMaDefaultConfigImpl { public interface JedisConfig { Jedis config(Jedis jedis); } private static final String ACCESS_TOKEN = "accessToken"; private static final String JSAPI_TICKET = "jsapiTicket"; private static final String CARD_API_TICKET = "cardApiTicket"; private static final String HASH_VALUE_FIELD = "value"; private static final String HASH_EXPIRE_FIELD = "expire"; /** * Redis Key 的前缀,默认为 maConfig */ private String redisKeyPrefix = "maConfig"; /** * 微信小程序唯一id,用于拼接存储到redis时的key,防止key重复. */ private String maId; private Lock accessTokenLock; private Lock jsapiTicketLock; private Lock cardApiTicketLock; /** * 临时文件目录. */ protected volatile File tmpDirFile; /** * 对从 JedisPool.getResource() 获取到的每个 Jedis 实例进行配置 */ private JedisConfig jedisConfig; protected abstract Jedis getJedis(); private Jedis getConfiguredJedis() { Jedis jedis = getJedis(); if (jedisConfig != null) { return jedisConfig.config(jedis); } else { return jedis; } } private String getRedisKey(String key) { StringBuilder redisKey = new StringBuilder(redisKeyPrefix).append(":"); if (maId == null) { return redisKey.append(key).toString(); } else { return redisKey.append(maId).append(":").append(key).toString(); } } private String getValueFromRedis(String key) { try (Jedis jedis = getConfiguredJedis()) { return jedis.hget(getRedisKey(key), HASH_VALUE_FIELD); } } private void setValueToRedis(String key, long expiresTime, String value) { try (Jedis jedis = getConfiguredJedis()) { Map<String, String> hash = new HashMap<>(); hash.put(HASH_VALUE_FIELD, value); hash.put(HASH_EXPIRE_FIELD, String.valueOf(expiresTime)); jedis.hmset(getRedisKey(key), hash); } } private long getExpireFromRedis(String key) { try (Jedis jedis = getConfiguredJedis()) { String expire = jedis.hget(getRedisKey(key), HASH_EXPIRE_FIELD); return expire == null ? 0 : Long.parseLong(expire); } } private void setExpire(String key, long expiresTime) { try (Jedis jedis = getConfiguredJedis()) { jedis.hset(getRedisKey(key), HASH_EXPIRE_FIELD, String.valueOf(expiresTime)); } } public void setRedisKeyPrefix(String redisKeyPrefix) { this.redisKeyPrefix = redisKeyPrefix; } public void setJedisConfig(JedisConfig jedisConfig) { this.jedisConfig = jedisConfig; } public void setMaId(String maId) { this.maId = maId; } @Override public String getAccessToken() { return getValueFromRedis(ACCESS_TOKEN); } @Override public Lock getAccessTokenLock() { if (accessTokenLock == null) { synchronized (this) { if (accessTokenLock == null) { accessTokenLock = new DistributedLock(getRedisKey("accessTokenLock")); } } } return accessTokenLock; } @Override public boolean isAccessTokenExpired() { return isExpired(getExpireFromRedis(ACCESS_TOKEN)); } @Override public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) { setValueToRedis(ACCESS_TOKEN, expiresAheadInMillis(expiresInSeconds), accessToken); } @Override public String getJsapiTicket() { return getValueFromRedis(JSAPI_TICKET); } @Override public Lock getJsapiTicketLock() { if (jsapiTicketLock == null) { synchronized (this) { if (jsapiTicketLock == null) { jsapiTicketLock = new DistributedLock(getRedisKey("jsapiTicketLock")); } } } return jsapiTicketLock; } @Override public boolean isJsapiTicketExpired() { return isExpired(getExpireFromRedis(JSAPI_TICKET)); } @Override public void expireJsapiTicket() { setExpire(JSAPI_TICKET, 0); } @Override public void updateJsapiTicket(String jsapiTicket, int expiresInSeconds) { setValueToRedis(JSAPI_TICKET, expiresAheadInMillis(expiresInSeconds), jsapiTicket); } @Override public String getCardApiTicket() { return getValueFromRedis(CARD_API_TICKET); } @Override public Lock getCardApiTicketLock() { if (cardApiTicketLock == null) { synchronized (this) { if (cardApiTicketLock == null) { cardApiTicketLock = new DistributedLock(getRedisKey("cardApiTicketLock")); } } } return cardApiTicketLock; } @Override public boolean isCardApiTicketExpired() { return isExpired(getExpireFromRedis(CARD_API_TICKET)); } @Override public void expireCardApiTicket() { setExpire(CARD_API_TICKET, 0); } @Override public void updateCardApiTicket(String cardApiTicket, int expiresInSeconds) { setValueToRedis(CARD_API_TICKET, expiresAheadInMillis(expiresInSeconds), cardApiTicket); } @Override public void expireAccessToken() { setExpiresTime(0); } @Override public long getExpiresTime() { return getExpireFromRedis(ACCESS_TOKEN); } @Override public void setExpiresTime(long expiresTime) { setExpire(ACCESS_TOKEN, expiresTime); } /** * 基于redis的简单分布式锁. */ private class DistributedLock implements Lock { private final String LOCK_SUCCESS = "OK"; private final Long RELEASE_SUCCESS = 1L; private String lockKey; private DistributedLock(String key) { this.lockKey = key; } @Override public void lock() { try (Jedis jedis = getConfiguredJedis()) { if (!acquire(jedis)) { throw new WxRuntimeException("acquire timeouted"); } } catch (InterruptedException e) { throw new WxRuntimeException("lock failed", e); } } @Override public void lockInterruptibly() throws InterruptedException { try (Jedis jedis = getConfiguredJedis()) { if (!acquire(jedis)) { throw new WxRuntimeException("acquire timeouted"); } } } @Override public boolean tryLock() { try (Jedis jedis = getConfiguredJedis()) { return acquire(jedis); } catch (InterruptedException e) { throw new WxRuntimeException("lock failed", e); } } @Override public boolean tryLock(long time, TimeUnit unit) throws InterruptedException { try (Jedis jedis = getConfiguredJedis()) { return acquire(jedis); } } @Override public void unlock() { try (Jedis jedis = getConfiguredJedis()) { releaseDistributedLock(jedis); } } @Override public Condition newCondition() { throw new WxRuntimeException("unsupported method"); } /** * 尝试获取锁 有限次数的重试 * * @param jedis * @return * @throws InterruptedException */ private Boolean acquire(Jedis jedis) throws InterruptedException { Integer i = 0; do { i++; boolean locked = tryGetDistributedLock(jedis); if (locked) { return true; } else { Thread.sleep(100L); } } while (i < 20); return false; } /** * 尝试获取锁 * * @param jedis * @return */ private Boolean tryGetDistributedLock(Jedis jedis) { Long millisecondsToExpire = 2L; Long threadId = Thread.currentThread().getId(); String result = jedis.set(this.lockKey, threadId.toString(), SetParams.setParams().nx().px(millisecondsToExpire)); return LOCK_SUCCESS.equals(result); } /** * 释放分布式锁 * * @param jedis * @return 是否释放成功 */ private Boolean releaseDistributedLock(Jedis jedis) { Long threadId = Thread.currentThread().getId(); String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end"; Object result = jedis.eval(script, Collections.singletonList(lockKey), Collections.singletonList(threadId.toString())); return RELEASE_SUCCESS.equals(result); } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaDefaultConfigImpl.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaDefaultConfigImpl.java
package cn.binarywang.wx.miniapp.config.impl; import cn.binarywang.wx.miniapp.config.WxMaConfig; import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; import java.io.File; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.function.Consumer; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import me.chanjar.weixin.common.bean.WxAccessTokenEntity; import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; /** * 基于内存的微信配置provider,在实际生产环境中应该将这些配置持久化 * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ @Getter public class WxMaDefaultConfigImpl implements WxMaConfig { protected volatile String appid; protected volatile String token; /** 是否使用稳定版获取accessToken接口 */ @Getter(value = AccessLevel.NONE) private boolean useStableAccessToken; /** 小程序原始ID */ protected volatile String originalId; protected Lock accessTokenLock = new ReentrantLock(); /** 临时文件目录. */ protected volatile File tmpDirFile; private volatile String msgDataFormat; private volatile String secret; private volatile String accessToken; private volatile String aesKey; private volatile long expiresTime; private volatile String apiSignatureRsaPrivateKey; private volatile String apiSignatureAesKey; private volatile String apiSignatureRsaPrivateKeySn; private volatile String apiSignatureAesKeySn; private volatile String wechatMpAppid; /** 云环境ID */ private volatile String cloudEnv; private volatile String httpProxyHost; private volatile int httpProxyPort; private volatile String httpProxyUsername; private volatile String httpProxyPassword; private volatile int retrySleepMillis = 1000; private volatile int maxRetryTimes = 5; private volatile String jsapiTicket; private volatile long jsapiTicketExpiresTime; /** 微信卡券的ticket单独缓存. */ private volatile String cardApiTicket; private volatile long cardApiTicketExpiresTime; protected volatile Lock jsapiTicketLock = new ReentrantLock(); protected volatile Lock cardApiTicketLock = new ReentrantLock(); private volatile ApacheHttpClientBuilder apacheHttpClientBuilder; private String apiHostUrl; private String accessTokenUrl; /** 是否使用微信云托管模式(使用 HTTP 协议访问内网地址) */ @Getter(AccessLevel.NONE) private boolean useWxCloudRun = false; /** 自定义配置token的消费者 */ @Setter private Consumer<WxAccessTokenEntity> updateAccessTokenBefore; /** 开启回调 */ @Getter(AccessLevel.NONE) private boolean enableUpdateAccessTokenBefore = true; /** 可临时关闭更新token回调,主要用于其他介质初始化数据时,可不进行回调 */ public void enableUpdateAccessTokenBefore(boolean enableUpdateAccessTokenBefore) { this.enableUpdateAccessTokenBefore = enableUpdateAccessTokenBefore; } /** 会过期的数据提前过期时间,默认预留200秒的时间 */ protected long expiresAheadInMillis(int expiresInSeconds) { return System.currentTimeMillis() + (expiresInSeconds - 200) * 1000L; } /** 判断 expiresTime 是否已经过期 */ protected boolean isExpired(long expiresTime) { return System.currentTimeMillis() > expiresTime; } @Override public String getAccessToken() { return this.accessToken; } public void setAccessToken(String accessToken) { this.accessToken = accessToken; } // region 使用稳定版接口获取accessToken @Override public boolean isStableAccessToken() { return this.useStableAccessToken; } @Override public void useStableAccessToken(boolean useStableAccessToken) { this.useStableAccessToken = useStableAccessToken; } // endregion @Override public Lock getAccessTokenLock() { return this.accessTokenLock; } public void setAccessTokenLock(Lock accessTokenLock) { this.accessTokenLock = accessTokenLock; } @Override public boolean isAccessTokenExpired() { return isExpired(this.expiresTime); } // @Override // public synchronized void updateAccessToken(WxAccessToken accessToken) { // updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); // } @Override public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) { setAccessToken(accessToken); setExpiresTime(expiresAheadInMillis(expiresInSeconds)); } @Override public void updateAccessTokenBefore(WxAccessTokenEntity wxAccessTokenEntity) { if (updateAccessTokenBefore != null && enableUpdateAccessTokenBefore) { updateAccessTokenBefore.accept(wxAccessTokenEntity); } } @Override public String getJsapiTicket() { return this.jsapiTicket; } @Override public Lock getJsapiTicketLock() { return this.jsapiTicketLock; } @Override public boolean isJsapiTicketExpired() { return isExpired(this.jsapiTicketExpiresTime); } @Override public void expireJsapiTicket() { this.jsapiTicketExpiresTime = 0; } @Override public void updateJsapiTicket(String jsapiTicket, int expiresInSeconds) { this.jsapiTicket = jsapiTicket; this.jsapiTicketExpiresTime = expiresAheadInMillis(expiresInSeconds); } @Override public String getCardApiTicket() { return this.cardApiTicket; } @Override public Lock getCardApiTicketLock() { return this.cardApiTicketLock; } @Override public boolean isCardApiTicketExpired() { return isExpired(this.cardApiTicketExpiresTime); } @Override public void expireCardApiTicket() { this.cardApiTicketExpiresTime = 0; } @Override public void updateCardApiTicket(String cardApiTicket, int expiresInSeconds) { this.cardApiTicket = cardApiTicket; this.cardApiTicketExpiresTime = expiresAheadInMillis(expiresInSeconds); } @Override public void expireAccessToken() { this.expiresTime = 0; } @Override public String getSecret() { return this.secret; } public void setSecret(String secret) { this.secret = secret; } @Override public String getToken() { return this.token; } public void setToken(String token) { this.token = token; } @Override public long getExpiresTime() { return this.expiresTime; } public void setExpiresTime(long expiresTime) { this.expiresTime = expiresTime; } @Override public String getAesKey() { return this.aesKey; } public void setAesKey(String aesKey) { this.aesKey = aesKey; } public String getApiSignatureRsaPrivateKey() { return apiSignatureRsaPrivateKey; } public void setApiSignatureRsaPrivateKey(String apiSignatureRsaPrivateKey) { this.apiSignatureRsaPrivateKey = apiSignatureRsaPrivateKey; } public String getApiSignatureAesKey() { return apiSignatureAesKey; } public void setApiSignatureAesKey(String apiSignatureAesKey) { this.apiSignatureAesKey = apiSignatureAesKey; } public String getApiSignatureRsaPrivateKeySn() { return apiSignatureRsaPrivateKeySn; } public void setApiSignatureRsaPrivateKeySn(String apiSignatureRsaPrivateKeySn) { this.apiSignatureRsaPrivateKeySn = apiSignatureRsaPrivateKeySn; } public String getApiSignatureAesKeySn() { return apiSignatureAesKeySn; } public void setApiSignatureAesKeySn(String apiSignatureAesKeySn) { this.apiSignatureAesKeySn = apiSignatureAesKeySn; } public String getWechatMpAppid() { return wechatMpAppid == null ? appid : wechatMpAppid; } public void setWechatMpAppid(String wechatMpAppid) { this.wechatMpAppid = wechatMpAppid; } @Override public String getOriginalId() { return originalId; } public void setOriginalId(String originalId) { this.originalId = originalId; } @Override public String getCloudEnv() { return this.cloudEnv; } public void setCloudEnv(String cloudEnv) { this.cloudEnv = cloudEnv; } @Override public String getMsgDataFormat() { return this.msgDataFormat; } public void setMsgDataFormat(String msgDataFormat) { this.msgDataFormat = msgDataFormat; } @Override public String getHttpProxyHost() { return this.httpProxyHost; } public void setHttpProxyHost(String httpProxyHost) { this.httpProxyHost = httpProxyHost; } @Override public int getHttpProxyPort() { return this.httpProxyPort; } public void setHttpProxyPort(int httpProxyPort) { this.httpProxyPort = httpProxyPort; } @Override public String getHttpProxyUsername() { return this.httpProxyUsername; } public void setHttpProxyUsername(String httpProxyUsername) { this.httpProxyUsername = httpProxyUsername; } @Override public String getHttpProxyPassword() { return this.httpProxyPassword; } public void setHttpProxyPassword(String httpProxyPassword) { this.httpProxyPassword = httpProxyPassword; } @Override public int getRetrySleepMillis() { return this.retrySleepMillis; } public void setRetrySleepMillis(int retrySleepMillis) { this.retrySleepMillis = retrySleepMillis; } @Override public int getMaxRetryTimes() { return this.maxRetryTimes; } public void setMaxRetryTimes(int maxRetryTimes) { this.maxRetryTimes = maxRetryTimes; } @Override public String toString() { return WxMaGsonBuilder.create().toJson(this); } @Override public ApacheHttpClientBuilder getApacheHttpClientBuilder() { return this.apacheHttpClientBuilder; } public void setApacheHttpClientBuilder(ApacheHttpClientBuilder apacheHttpClientBuilder) { this.apacheHttpClientBuilder = apacheHttpClientBuilder; } @Override public boolean autoRefreshToken() { return true; } @Override public void setApiHostUrl(String apiHostUrl) { this.apiHostUrl = apiHostUrl; } @Override public void setAccessTokenUrl(String accessTokenUrl) { this.accessTokenUrl = accessTokenUrl; } @Override public boolean isUseWxCloudRun() { return this.useWxCloudRun; } @Override public void setUseWxCloudRun(boolean useWxCloudRun) { this.useWxCloudRun = useWxCloudRun; } @Override public String getAppid() { return appid; } public void setAppid(String appid) { this.appid = appid; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedisBetterConfigImpl.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedisBetterConfigImpl.java
package cn.binarywang.wx.miniapp.config.impl; import me.chanjar.weixin.common.enums.TicketType; import me.chanjar.weixin.common.redis.WxRedisOps; import java.util.concurrent.TimeUnit; /** * 基于redis存储的微信小程序配置类 * * @author Mario Luo, 2020-04-18 23:08 */ public class WxMaRedisBetterConfigImpl extends WxMaDefaultConfigImpl { private static final String ACCESS_TOKEN_KEY_TPL = "%s:access_token:%s"; private static final String TICKET_KEY_TPL = "%s:ticket:key:%s:%s"; private static final String LOCK_KEY_TPL = "%s:lock:%s:"; private final WxRedisOps redisOps; private final String keyPrefix; private volatile String accessTokenKey; private volatile String lockKey; public WxMaRedisBetterConfigImpl(WxRedisOps redisOps, String keyPrefix) { this.redisOps = redisOps; this.keyPrefix = keyPrefix; } @Override public void setAppid(String appId) { super.setAppid(appId); this.accessTokenKey = String.format(ACCESS_TOKEN_KEY_TPL, this.keyPrefix, appId); this.lockKey = String.format(LOCK_KEY_TPL, this.keyPrefix, appId); super.accessTokenLock = this.redisOps.getLock(lockKey.concat("accessTokenLock")); super.jsapiTicketLock = this.redisOps.getLock(lockKey.concat("jsapiTicketLock")); super.cardApiTicketLock = this.redisOps.getLock(lockKey.concat("cardApiTicketLock")); } //------------------------------------------------------------------------ // token相关 //------------------------------------------------------------------------ @Override public String getAccessToken() { return redisOps.getValue(this.accessTokenKey); } @Override public boolean isAccessTokenExpired() { Long expire = redisOps.getExpire(this.accessTokenKey); return expire == null || expire < 2; } @Override public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) { redisOps.setValue(this.accessTokenKey, accessToken, expiresInSeconds - 200, TimeUnit.SECONDS); } @Override public void expireAccessToken() { redisOps.expire(this.accessTokenKey, 0, TimeUnit.SECONDS); } //------------------------------------------------------------------------ // ticket相关 //------------------------------------------------------------------------ @Override public String getJsapiTicket() { return doGetTicket(TicketType.JSAPI); } @Override public boolean isJsapiTicketExpired() { return doIsTicketExpired(TicketType.JSAPI); } @Override public void expireJsapiTicket() { doExpireTicket(TicketType.JSAPI); } @Override public synchronized void updateJsapiTicket(String jsapiTicket, int expiresInSeconds) { doUpdateTicket(TicketType.JSAPI, jsapiTicket, expiresInSeconds); } @Override public String getCardApiTicket() { return doGetTicket(TicketType.WX_CARD); } @Override public boolean isCardApiTicketExpired() { return doIsTicketExpired(TicketType.WX_CARD); } @Override public void expireCardApiTicket() { doExpireTicket(TicketType.WX_CARD); } @Override public synchronized void updateCardApiTicket(String cardApiTicket, int expiresInSeconds) { doUpdateTicket(TicketType.WX_CARD, cardApiTicket, expiresInSeconds); } private String getTicketRedisKey(TicketType type) { return String.format(TICKET_KEY_TPL, this.keyPrefix, this.appid, type.getCode()); } private String doGetTicket(TicketType type) { return redisOps.getValue(this.getTicketRedisKey(type)); } private boolean doIsTicketExpired(TicketType type) { return redisOps.getExpire(this.getTicketRedisKey(type)) < 2; } private void doUpdateTicket(TicketType type, String ticket, int expiresInSeconds) { redisOps.setValue(this.getTicketRedisKey(type), ticket, expiresInSeconds - 200, TimeUnit.SECONDS); } private void doExpireTicket(TicketType type) { redisOps.expire(this.getTicketRedisKey(type), 0, TimeUnit.SECONDS); } @Override public String toString() { return "WxMaRedisBetterConfigImpl{" + "appid='" + appid + '\'' + ", token='" + token + '\'' + ", originalId='" + originalId + '\'' + ", accessTokenLock=" + accessTokenLock + ", tmpDirFile=" + tmpDirFile + ", jsapiTicketLock=" + jsapiTicketLock + ", cardApiTicketLock=" + cardApiTicketLock + ", redisOps=" + redisOps + ", keyPrefix='" + keyPrefix + '\'' + ", accessTokenKey='" + accessTokenKey + '\'' + ", lockKey='" + lockKey + '\'' + '}'; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedisConfigImpl.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedisConfigImpl.java
package cn.binarywang.wx.miniapp.config.impl; import org.apache.commons.lang3.builder.ToStringBuilder; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; /** * 基于Redis的微信配置provider. 使用连接池 JedisPool 进行 Redis 操作。 * * <pre> * 需要引入依赖<a href="https://github.com/abelaska/jedis-lock">jedis-lock</a>,才能使用该类。 * </pre> * * @author <a href="https://github.com/winter4666">winter</a> */ public class WxMaRedisConfigImpl extends AbstractWxMaRedisConfig { private JedisPool jedisPool; private static final String ACCESS_TOKEN_KEY = "wa:access_token:"; private String accessTokenKey; /** * JedisPool 在此配置类是必须项,使用 WxMaRedisConfigImpl(JedisPool) 构造方法来构造实例 */ @Deprecated public WxMaRedisConfigImpl() { } public WxMaRedisConfigImpl(JedisPool jedisPool) { this.jedisPool = jedisPool; } /** * 使用 WxMaRedisConfigImpl(JedisPool) 构造方法来设置 JedisPool */ @Deprecated public void setJedisPool(JedisPool jedisPool) { this.jedisPool = jedisPool; } @Override protected Jedis getJedis() { return jedisPool.getResource(); } /** * 每个公众号生成独有的存储key. */ @Override public void setAppid(String appId) { super.setAppid(appId); this.accessTokenKey = ACCESS_TOKEN_KEY.concat(appId); } @Override public String getAccessToken() { try (Jedis jedis = this.jedisPool.getResource()) { return jedis.get(this.accessTokenKey); } } @Override public boolean isAccessTokenExpired() { try (Jedis jedis = this.jedisPool.getResource()) { return jedis.ttl(accessTokenKey) < 2; } } @Override public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) { try (Jedis jedis = this.jedisPool.getResource()) { jedis.setex(this.accessTokenKey, expiresInSeconds - 200, accessToken); } } @Override public void expireAccessToken() { try (Jedis jedis = this.jedisPool.getResource()) { jedis.expire(this.accessTokenKey, 0); } } @Override public String toString() { return ToStringBuilder.reflectionToString(this); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedisConnectionConfigImpl.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedisConnectionConfigImpl.java
package cn.binarywang.wx.miniapp.config.impl; import lombok.RequiredArgsConstructor; import redis.clients.jedis.Jedis; /** * 基于Redis的微信配置provider. 使用自己管理的 Jedis 实例进行 Redis 操作。 * * <pre> * 需要引入依赖<a href="https://github.com/abelaska/jedis-lock">jedis-lock</a>,才能使用该类。 * </pre> */ @RequiredArgsConstructor public class WxMaRedisConnectionConfigImpl extends AbstractWxMaRedisConfig { private final Jedis jedis; @Override protected Jedis getJedis() { return jedis; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedissonConfigImpl.java
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/config/impl/WxMaRedissonConfigImpl.java
package cn.binarywang.wx.miniapp.config.impl; import lombok.NonNull; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.redis.RedissonWxRedisOps; import me.chanjar.weixin.common.redis.WxRedisOps; import org.apache.commons.lang3.StringUtils; import org.redisson.api.RedissonClient; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; /** * 基于Redisson的实现 * * @author yuanqixun * created on 2020/5/3 */ public class WxMaRedissonConfigImpl extends WxMaDefaultConfigImpl { protected static final String LOCK_KEY = "wechat_ma_lock:"; protected static final String MA_ACCESS_TOKEN_KEY = "wechat_ma_access_token_key:"; protected static final String MA_JSAPI_TICKET_KEY = "wechat_ma_jsapi_ticket_key:"; protected static final String MA_CARD_API_TICKET_KEY = "wechat_ma_card_api_ticket_key:"; /** * redis 存储的 key 的前缀,可为空 */ protected String keyPrefix; protected String accessTokenKey; protected String jsapiTicketKey; protected String cardApiTicketKey; protected String lockKey; private final WxRedisOps redisOps; public WxMaRedissonConfigImpl(@NonNull RedissonClient redissonClient, String keyPrefix) { this(new RedissonWxRedisOps(redissonClient), keyPrefix); } public WxMaRedissonConfigImpl(@NonNull RedissonClient redissonClient) { this(redissonClient, null); } private WxMaRedissonConfigImpl(@NonNull WxRedisOps redisOps, String keyPrefix) { this.redisOps = redisOps; this.keyPrefix = keyPrefix; } @Override public void setAppid(String appid) { super.setAppid(appid); String prefix = StringUtils.isBlank(keyPrefix) ? "" : (StringUtils.endsWith(keyPrefix, ":") ? keyPrefix : (keyPrefix + ":")); lockKey = prefix + LOCK_KEY.concat(appid); accessTokenKey = prefix + MA_ACCESS_TOKEN_KEY.concat(appid); jsapiTicketKey = prefix + MA_JSAPI_TICKET_KEY.concat(appid); cardApiTicketKey = prefix + MA_CARD_API_TICKET_KEY.concat(appid); } protected Lock getLockByKey(String key) { return redisOps.getLock(key); } @Override public Lock getAccessTokenLock() { return getLockByKey(this.lockKey.concat(":").concat("accessToken")); } @Override public Lock getCardApiTicketLock() { return getLockByKey(this.lockKey.concat(":").concat("cardApiTicket")); } @Override public Lock getJsapiTicketLock() { return getLockByKey(this.lockKey.concat(":").concat("jsapiTicket")); } @Override public String getAccessToken() { return redisOps.getValue(this.accessTokenKey); } @Override public boolean isAccessTokenExpired() { Long expire = redisOps.getExpire(this.accessTokenKey); return expire == null || expire < 2; } @Override public void updateAccessToken(WxAccessToken accessToken) { updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); } @Override public void updateAccessToken(String accessToken, int expiresInSeconds) { redisOps.setValue(this.accessTokenKey, accessToken, expiresInSeconds, TimeUnit.SECONDS); } @Override public String getJsapiTicket() { return redisOps.getValue(this.jsapiTicketKey); } @Override public boolean isJsapiTicketExpired() { Long expire = redisOps.getExpire(this.jsapiTicketKey); return expire == null || expire < 2; } @Override public void expireJsapiTicket() { redisOps.expire(this.jsapiTicketKey, 0, TimeUnit.SECONDS); } @Override public void updateJsapiTicket(String jsapiTicket, int expiresInSeconds) { redisOps.setValue(this.jsapiTicketKey, jsapiTicket, expiresInSeconds, TimeUnit.SECONDS); } @Override public String getCardApiTicket() { return redisOps.getValue(cardApiTicketKey); } @Override public boolean isCardApiTicketExpired() { Long expire = redisOps.getExpire(this.cardApiTicketKey); return expire == null || expire < 2; } @Override public void expireCardApiTicket() { redisOps.expire(this.cardApiTicketKey, 0, TimeUnit.SECONDS); } @Override public void updateCardApiTicket(String cardApiTicket, int expiresInSeconds) { redisOps.setValue(this.cardApiTicketKey, cardApiTicket, expiresInSeconds, TimeUnit.SECONDS); } @Override public void expireAccessToken() { redisOps.expire(this.accessTokenKey, 0, TimeUnit.SECONDS); } @Override public long getExpiresTime() { return redisOps.getExpire(this.accessTokenKey); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-graal/src/main/java/com/github/binarywang/wx/graal/GraalProcessor.java
weixin-graal/src/main/java/com/github/binarywang/wx/graal/GraalProcessor.java
package com.github.binarywang.wx.graal; import lombok.Data; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; import javax.lang.model.element.TypeElement; import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; import javax.tools.FileObject; import javax.tools.StandardLocation; import java.io.IOException; import java.io.Writer; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; /** * 目前仅仅处理@Data,且必须在lombok自己的processor之前执行,千万注意!!!!! * * @author outersky */ @SupportedAnnotationTypes("lombok.Data") @SupportedSourceVersion(SourceVersion.RELEASE_8) public class GraalProcessor extends AbstractProcessor { private static final String REFLECTION_CONFIG_JSON = "reflection-config.json"; private static final String NATIVE_IMAGE_PROPERTIES = "native-image.properties"; private final SortedSet<String> classSet = new TreeSet<>(); private String shortestPackageName = null; @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (TypeElement annotatedClass : ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(Data.class))) { registerClass(annotatedClass.getQualifiedName().toString()); handleSuperClass(annotatedClass); } //只有最后一轮才可以写文件,否则文件会被重复打开,报错! if (!roundEnv.processingOver()) { return false; } // 如果没有文件要写,跳过 if (classSet.isEmpty()) { return false; } writeFiles(); //必须返回false,以便让lombok能继续处理。 return false; } /** * 设置当前最短的package名称 * * @param packageName 包名 */ private void setShortestPackageName(String packageName) { if (shortestPackageName == null) { shortestPackageName = packageName; } else if (packageName.length() < shortestPackageName.length()) { shortestPackageName = packageName; } } /** * 更加完整的类名来获取package名称 * * @param fullClassName 完整的类名 * @return package name */ private String getPackageName(String fullClassName) { int last = fullClassName.lastIndexOf('.'); if (last == -1) { return fullClassName; } return fullClassName.substring(0, last); } /** * 保存文件 * META-INF/native-image/.../reflection-config.json * META-INF/native-image/.../native-image.properties */ private void writeFiles() { String basePackage = shortestPackageName; String module; if (basePackage.contains(".")) { final int i = basePackage.lastIndexOf('.'); module = basePackage.substring(i + 1); basePackage = basePackage.substring(0, i); } else { module = basePackage; } String path = "META-INF/native-image/" + basePackage + "/" + module + "/"; String reflectFile = path + REFLECTION_CONFIG_JSON; String propsFile = path + NATIVE_IMAGE_PROPERTIES; try { FileObject fileObject = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", propsFile); try (Writer writer = fileObject.openWriter();) { writer.append("Args = -H:ReflectionConfigurationResources=${.}/" + REFLECTION_CONFIG_JSON); } } catch (IOException e) { e.printStackTrace(); } try { FileObject fileObject = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", reflectFile); try (Writer writer = fileObject.openWriter();) { writer.write("[\n"); boolean first = true; for (String name : classSet) { if (first) { first = false; } else { writer.write(","); } writer.write(assetGraalJsonElement(name)); writer.append('\n'); } writer.write("]"); } } catch (IOException e) { e.printStackTrace(); } } private String assetGraalJsonElement(String className) { return "{\n" + " \"name\" : \"" + className + "\",\n" + " \"allDeclaredFields\":true,\n" + " \"allDeclaredMethods\":true,\n" + " \"allDeclaredConstructors\":true,\n" + " \"allPublicMethods\" : true\n" + "}"; } /** * 登记一个class * * @param className 完整的类名 */ private void registerClass(String className) { classSet.add(className); setShortestPackageName(getPackageName(className)); } /** * 获取一个类型的所有的父类,并登记 * * @param typeElement 类型元素 */ private void handleSuperClass(TypeElement typeElement) { TypeMirror superclass = typeElement.getSuperclass(); if (superclass.getKind() == TypeKind.DECLARED) { TypeElement s = (TypeElement) ((DeclaredType) superclass).asElement(); String sName = s.toString(); // ignore java.**/javax.** if (sName.startsWith("java.") || sName.startsWith("javax.")) { return; } registerClass(sName); handleSuperClass(s); } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-solon-plugin/src/test/java/features/test/LoadTest.java
solon-plugins/wx-java-channel-solon-plugin/src/test/java/features/test/LoadTest.java
package features.test; import org.junit.jupiter.api.Test; import org.noear.solon.test.SolonTest; /** * @author noear 2024/9/4 created */ @SolonTest public class LoadTest { @Test public void load(){ } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/integration/WxChannelPluginImpl.java
solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/integration/WxChannelPluginImpl.java
package com.binarywang.solon.wxjava.channel.integration; import com.binarywang.solon.wxjava.channel.config.WxChannelServiceAutoConfiguration; import com.binarywang.solon.wxjava.channel.config.storage.WxChannelInJedisConfigStorageConfiguration; import com.binarywang.solon.wxjava.channel.config.storage.WxChannelInMemoryConfigStorageConfiguration; import com.binarywang.solon.wxjava.channel.config.storage.WxChannelInRedissonConfigStorageConfiguration; import com.binarywang.solon.wxjava.channel.properties.WxChannelProperties; import org.noear.solon.core.AppContext; import org.noear.solon.core.Plugin; /** * @author noear 2024/9/2 created */ public class WxChannelPluginImpl implements Plugin { @Override public void start(AppContext context) throws Throwable { context.beanMake(WxChannelProperties.class); context.beanMake(WxChannelServiceAutoConfiguration.class); context.beanMake(WxChannelInMemoryConfigStorageConfiguration.class); context.beanMake(WxChannelInJedisConfigStorageConfiguration.class); context.beanMake(WxChannelInRedissonConfigStorageConfiguration.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/properties/RedisProperties.java
solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/properties/RedisProperties.java
package com.binarywang.solon.wxjava.channel.properties; import lombok.Data; /** * redis 配置 * * @author <a href="https://github.com/lixize">Zeyes</a> */ @Data public class RedisProperties { /** * 主机地址,不填则从solon容器内获取JedisPool */ private String host; /** * 端口号 */ private int port = 6379; /** * 密码 */ private String password; /** * 超时 */ private int timeout = 2000; /** * 数据库 */ private int database = 0; private Integer maxActive; private Integer maxIdle; private Integer maxWaitMillis; private Integer minIdle; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/properties/WxChannelProperties.java
solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/properties/WxChannelProperties.java
package com.binarywang.solon.wxjava.channel.properties; import com.binarywang.solon.wxjava.channel.enums.HttpClientType; import com.binarywang.solon.wxjava.channel.enums.StorageType; import lombok.Data; import org.noear.solon.annotation.Configuration; import org.noear.solon.annotation.Inject; /** * 属性配置类 * * @author <a href="https://github.com/lixize">Zeyes</a> */ @Data @Configuration @Inject("${" + WxChannelProperties.PREFIX +"}") public class WxChannelProperties { public static final String PREFIX = "wx.channel"; /** * 设置视频号小店的appid */ private String appid; /** * 设置视频号小店的Secret */ private String secret; /** * 设置视频号小店消息服务器配置的token. */ private String token; /** * 设置视频号小店消息服务器配置的EncodingAESKey */ private String aesKey; /** * 消息格式,XML或者JSON */ private String msgDataFormat = "JSON"; /** * 是否使用稳定版 Access Token */ private boolean useStableAccessToken = false; /** * 存储策略 */ private final ConfigStorage configStorage = new ConfigStorage(); @Data public static class ConfigStorage { /** * 存储类型 */ private StorageType type = StorageType.Memory; /** * 指定key前缀 */ private String keyPrefix = "wh"; /** * redis连接配置 */ private final RedisProperties redis = new RedisProperties(); /** * http客户端类型 */ private HttpClientType httpClientType = HttpClientType.HttpClient; /** * http代理主机 */ private String httpProxyHost; /** * http代理端口 */ private Integer httpProxyPort; /** * http代理用户名 */ private String httpProxyUsername; /** * http代理密码 */ private String httpProxyPassword; /** * http 请求重试间隔 * <pre> * {@link me.chanjar.weixin.channel.api.BaseWxChannelService#setRetrySleepMillis(int)} * </pre> */ private int retrySleepMillis = 1000; /** * http 请求最大重试次数 * <pre> * {@link me.chanjar.weixin.channel.api.BaseWxChannelService#setMaxRetryTimes(int)} * </pre> */ private int maxRetryTimes = 5; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/config/WxChannelServiceAutoConfiguration.java
solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/config/WxChannelServiceAutoConfiguration.java
package com.binarywang.solon.wxjava.channel.config; import com.binarywang.solon.wxjava.channel.properties.WxChannelProperties; import lombok.AllArgsConstructor; import me.chanjar.weixin.channel.api.WxChannelService; import me.chanjar.weixin.channel.api.impl.WxChannelServiceImpl; import me.chanjar.weixin.channel.config.WxChannelConfig; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; /** * 微信小程序平台相关服务自动注册 * * @author <a href="https://github.com/lixize">Zeyes</a> */ @Configuration @AllArgsConstructor public class WxChannelServiceAutoConfiguration { private final WxChannelProperties properties; /** * Channel Service * * @return Channel Service */ @Bean @Condition(onMissingBean=WxChannelService.class, onBean = WxChannelConfig.class) public WxChannelService wxChannelService(WxChannelConfig wxChannelConfig) { WxChannelService wxChannelService = new WxChannelServiceImpl(); wxChannelService.setConfig(wxChannelConfig); return wxChannelService; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/config/storage/AbstractWxChannelConfigStorageConfiguration.java
solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/config/storage/AbstractWxChannelConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.channel.config.storage; import com.binarywang.solon.wxjava.channel.properties.WxChannelProperties; import me.chanjar.weixin.channel.config.impl.WxChannelDefaultConfigImpl; import org.apache.commons.lang3.StringUtils; /** * @author <a href="https://github.com/lixize">Zeyes</a> */ public abstract class AbstractWxChannelConfigStorageConfiguration { protected WxChannelDefaultConfigImpl config(WxChannelDefaultConfigImpl config, WxChannelProperties properties) { config.setAppid(StringUtils.trimToNull(properties.getAppid())); config.setSecret(StringUtils.trimToNull(properties.getSecret())); config.setToken(StringUtils.trimToNull(properties.getToken())); config.setAesKey(StringUtils.trimToNull(properties.getAesKey())); config.setMsgDataFormat(StringUtils.trimToNull(properties.getMsgDataFormat())); config.setStableAccessToken(properties.isUseStableAccessToken()); WxChannelProperties.ConfigStorage configStorageProperties = properties.getConfigStorage(); config.setHttpProxyHost(configStorageProperties.getHttpProxyHost()); config.setHttpProxyUsername(configStorageProperties.getHttpProxyUsername()); config.setHttpProxyPassword(configStorageProperties.getHttpProxyPassword()); if (configStorageProperties.getHttpProxyPort() != null) { config.setHttpProxyPort(configStorageProperties.getHttpProxyPort()); } int maxRetryTimes = configStorageProperties.getMaxRetryTimes(); if (configStorageProperties.getMaxRetryTimes() < 0) { maxRetryTimes = 0; } int retrySleepMillis = configStorageProperties.getRetrySleepMillis(); if (retrySleepMillis < 0) { retrySleepMillis = 1000; } config.setRetrySleepMillis(retrySleepMillis); config.setMaxRetryTimes(maxRetryTimes); return config; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/config/storage/WxChannelInMemoryConfigStorageConfiguration.java
solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/config/storage/WxChannelInMemoryConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.channel.config.storage; import com.binarywang.solon.wxjava.channel.properties.WxChannelProperties; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.channel.config.WxChannelConfig; import me.chanjar.weixin.channel.config.impl.WxChannelDefaultConfigImpl; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; /** * @author <a href="https://github.com/lixize">Zeyes</a> */ @Configuration @Condition( onProperty = "${"+WxChannelProperties.PREFIX + ".configStorage.type:memory} = memory" ) @RequiredArgsConstructor public class WxChannelInMemoryConfigStorageConfiguration extends AbstractWxChannelConfigStorageConfiguration { private final WxChannelProperties properties; @Bean @Condition(onMissingBean = WxChannelProperties.class) public WxChannelConfig wxChannelConfig() { WxChannelDefaultConfigImpl config = new WxChannelDefaultConfigImpl(); return this.config(config, properties); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/config/storage/WxChannelInJedisConfigStorageConfiguration.java
solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/config/storage/WxChannelInJedisConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.channel.config.storage; import com.binarywang.solon.wxjava.channel.properties.RedisProperties; import com.binarywang.solon.wxjava.channel.properties.WxChannelProperties; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.channel.config.WxChannelConfig; import me.chanjar.weixin.channel.config.impl.WxChannelRedisConfigImpl; import me.chanjar.weixin.common.redis.JedisWxRedisOps; import me.chanjar.weixin.common.redis.WxRedisOps; import org.apache.commons.lang3.StringUtils; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; import org.noear.solon.core.AppContext; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig; /** * @author <a href="https://github.com/lixize">Zeyes</a> * @author noear */ @Configuration @Condition( onProperty = "${"+WxChannelProperties.PREFIX + ".configStorage.type} = jedis", onClass = JedisPool.class ) @RequiredArgsConstructor public class WxChannelInJedisConfigStorageConfiguration extends AbstractWxChannelConfigStorageConfiguration { private final WxChannelProperties properties; private final AppContext applicationContext; @Bean @Condition(onMissingBean=WxChannelConfig.class) public WxChannelConfig wxChannelConfig() { WxChannelRedisConfigImpl config = getWxChannelRedisConfig(); return this.config(config, properties); } private WxChannelRedisConfigImpl getWxChannelRedisConfig() { RedisProperties redisProperties = properties.getConfigStorage().getRedis(); JedisPool jedisPool; if (redisProperties != null && StringUtils.isNotEmpty(redisProperties.getHost())) { jedisPool = getJedisPool(); } else { jedisPool = applicationContext.getBean(JedisPool.class); } WxRedisOps redisOps = new JedisWxRedisOps(jedisPool); return new WxChannelRedisConfigImpl(redisOps, properties.getConfigStorage().getKeyPrefix()); } private JedisPool getJedisPool() { WxChannelProperties.ConfigStorage storage = properties.getConfigStorage(); RedisProperties redis = storage.getRedis(); JedisPoolConfig config = new JedisPoolConfig(); if (redis.getMaxActive() != null) { config.setMaxTotal(redis.getMaxActive()); } if (redis.getMaxIdle() != null) { config.setMaxIdle(redis.getMaxIdle()); } if (redis.getMaxWaitMillis() != null) { config.setMaxWaitMillis(redis.getMaxWaitMillis()); } if (redis.getMinIdle() != null) { config.setMinIdle(redis.getMinIdle()); } config.setTestOnBorrow(true); config.setTestWhileIdle(true); return new JedisPool(config, redis.getHost(), redis.getPort(), redis.getTimeout(), redis.getPassword(), redis.getDatabase()); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/config/storage/WxChannelInRedissonConfigStorageConfiguration.java
solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/config/storage/WxChannelInRedissonConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.channel.config.storage; import com.binarywang.solon.wxjava.channel.properties.RedisProperties; import com.binarywang.solon.wxjava.channel.properties.WxChannelProperties; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.channel.config.WxChannelConfig; import me.chanjar.weixin.channel.config.impl.WxChannelRedissonConfigImpl; import org.apache.commons.lang3.StringUtils; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; import org.noear.solon.core.AppContext; import org.redisson.Redisson; import org.redisson.api.RedissonClient; import org.redisson.config.Config; import org.redisson.config.TransportMode; /** * @author <a href="https://github.com/lixize">Zeyes</a> */ @Configuration @Condition( onProperty = "${"+WxChannelProperties.PREFIX + ".configStorage.type} = redisson", onClass = Redisson.class ) @RequiredArgsConstructor public class WxChannelInRedissonConfigStorageConfiguration extends AbstractWxChannelConfigStorageConfiguration { private final WxChannelProperties properties; private final AppContext applicationContext; @Bean @Condition(onMissingBean=WxChannelConfig.class) public WxChannelConfig wxChannelConfig() { WxChannelRedissonConfigImpl config = getWxChannelRedissonConfig(); return this.config(config, properties); } private WxChannelRedissonConfigImpl getWxChannelRedissonConfig() { RedisProperties redisProperties = properties.getConfigStorage().getRedis(); RedissonClient redissonClient; if (redisProperties != null && StringUtils.isNotEmpty(redisProperties.getHost())) { redissonClient = getRedissonClient(); } else { redissonClient = applicationContext.getBean(RedissonClient.class); } return new WxChannelRedissonConfigImpl(redissonClient, properties.getConfigStorage().getKeyPrefix()); } private RedissonClient getRedissonClient() { WxChannelProperties.ConfigStorage storage = properties.getConfigStorage(); RedisProperties redis = storage.getRedis(); Config config = new Config(); config.useSingleServer() .setAddress("redis://" + redis.getHost() + ":" + redis.getPort()) .setDatabase(redis.getDatabase()) .setPassword(redis.getPassword()); config.setTransportMode(TransportMode.NIO); return Redisson.create(config); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/enums/HttpClientType.java
solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/enums/HttpClientType.java
package com.binarywang.solon.wxjava.channel.enums; /** * httpclient类型 * * @author <a href="https://github.com/lixize">Zeyes</a> */ public enum HttpClientType { /** * HttpClient */ HttpClient }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/enums/StorageType.java
solon-plugins/wx-java-channel-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/enums/StorageType.java
package com.binarywang.solon.wxjava.channel.enums; /** * storage类型 * * @author <a href="https://github.com/lixize">Zeyes</a> */ public enum StorageType { /** * 内存 */ Memory, /** * redis(JedisClient) */ Jedis, /** * redis(Redisson) */ Redisson, /** * redis(RedisTemplate) */ RedisTemplate }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-cp-solon-plugin/src/test/java/features/test/LoadTest.java
solon-plugins/wx-java-cp-solon-plugin/src/test/java/features/test/LoadTest.java
package features.test; import org.junit.jupiter.api.Test; import org.noear.solon.test.SolonTest; /** * @author noear 2024/9/4 created */ @SolonTest public class LoadTest { @Test public void load(){ } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/storage/WxCpInRedissonConfigStorageConfiguration.java
solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/storage/WxCpInRedissonConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.cp.storage; import com.binarywang.solon.wxjava.cp.properties.WxCpProperties; import com.binarywang.solon.wxjava.cp.properties.WxCpRedisProperties; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; import me.chanjar.weixin.cp.config.impl.WxCpRedissonConfigImpl; import org.apache.commons.lang3.StringUtils; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; import org.noear.solon.core.AppContext; import org.redisson.Redisson; import org.redisson.api.RedissonClient; import org.redisson.config.Config; import org.redisson.config.TransportMode; /** * 自动装配基于 redisson 策略配置 * * @author yl * created on 2023/04/23 */ @Configuration @Condition( onProperty = "${"+WxCpProperties.PREFIX + ".configStorage.type} = redisson", onClass = Redisson.class ) @RequiredArgsConstructor public class WxCpInRedissonConfigStorageConfiguration extends AbstractWxCpConfigStorageConfiguration { private final WxCpProperties wxCpProperties; private final AppContext applicationContext; @Bean @Condition(onMissingBean=WxCpConfigStorage.class) public WxCpConfigStorage wxCpConfigStorage() { WxCpDefaultConfigImpl config = getConfigStorage(); return this.config(config, wxCpProperties); } private WxCpRedissonConfigImpl getConfigStorage() { WxCpRedisProperties redisProperties = wxCpProperties.getConfigStorage().getRedis(); RedissonClient redissonClient; if (redisProperties != null && StringUtils.isNotEmpty(redisProperties.getHost())) { redissonClient = getRedissonClient(); } else { redissonClient = applicationContext.getBean(RedissonClient.class); } return new WxCpRedissonConfigImpl(redissonClient, wxCpProperties.getConfigStorage().getKeyPrefix()); } private RedissonClient getRedissonClient() { WxCpProperties.ConfigStorage storage = wxCpProperties.getConfigStorage(); WxCpRedisProperties redis = storage.getRedis(); Config config = new Config(); config.useSingleServer() .setAddress("redis://" + redis.getHost() + ":" + redis.getPort()) .setDatabase(redis.getDatabase()) .setPassword(redis.getPassword()); config.setTransportMode(TransportMode.NIO); return Redisson.create(config); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/storage/WxCpInMemoryConfigStorageConfiguration.java
solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/storage/WxCpInMemoryConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.cp.storage; import com.binarywang.solon.wxjava.cp.properties.WxCpProperties; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; /** * 自动装配基于内存策略配置 * * @author yl * created on 2021/12/6 */ @Configuration @Condition( onProperty = "${"+WxCpProperties.PREFIX + ".configStorage.type:memory} = memory" ) @RequiredArgsConstructor public class WxCpInMemoryConfigStorageConfiguration extends AbstractWxCpConfigStorageConfiguration { private final WxCpProperties wxCpProperties; @Bean @Condition(onMissingBean=WxCpConfigStorage.class) public WxCpConfigStorage wxCpConfigStorage() { WxCpDefaultConfigImpl config = new WxCpDefaultConfigImpl(); return this.config(config, wxCpProperties); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/storage/AbstractWxCpConfigStorageConfiguration.java
solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/storage/AbstractWxCpConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.cp.storage; import com.binarywang.solon.wxjava.cp.properties.WxCpProperties; import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; import org.apache.commons.lang3.StringUtils; /** * WxCpConfigStorage 抽象配置类 * * @author yl & Wang_Wong * created on 2021/12/6 */ public abstract class AbstractWxCpConfigStorageConfiguration { protected WxCpDefaultConfigImpl config(WxCpDefaultConfigImpl config, WxCpProperties properties) { String corpId = properties.getCorpId(); String corpSecret = properties.getCorpSecret(); Integer agentId = properties.getAgentId(); String token = properties.getToken(); String aesKey = properties.getAesKey(); // 企业微信,私钥,会话存档路径 String msgAuditPriKey = properties.getMsgAuditPriKey(); String msgAuditLibPath = properties.getMsgAuditLibPath(); config.setCorpId(corpId); config.setCorpSecret(corpSecret); config.setAgentId(agentId); if (StringUtils.isNotBlank(token)) { config.setToken(token); } if (StringUtils.isNotBlank(aesKey)) { config.setAesKey(aesKey); } if (StringUtils.isNotBlank(msgAuditPriKey)) { config.setMsgAuditPriKey(msgAuditPriKey); } if (StringUtils.isNotBlank(msgAuditLibPath)) { config.setMsgAuditLibPath(msgAuditLibPath); } WxCpProperties.ConfigStorage storage = properties.getConfigStorage(); String httpProxyHost = storage.getHttpProxyHost(); Integer httpProxyPort = storage.getHttpProxyPort(); String httpProxyUsername = storage.getHttpProxyUsername(); String httpProxyPassword = storage.getHttpProxyPassword(); if (StringUtils.isNotBlank(httpProxyHost)) { config.setHttpProxyHost(httpProxyHost); if (httpProxyPort != null) { config.setHttpProxyPort(httpProxyPort); } if (StringUtils.isNotBlank(httpProxyUsername)) { config.setHttpProxyUsername(httpProxyUsername); } if (StringUtils.isNotBlank(httpProxyPassword)) { config.setHttpProxyPassword(httpProxyPassword); } } return config; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/storage/WxCpInJedisConfigStorageConfiguration.java
solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/storage/WxCpInJedisConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.cp.storage; import com.binarywang.solon.wxjava.cp.properties.WxCpProperties; import com.binarywang.solon.wxjava.cp.properties.WxCpRedisProperties; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl; import me.chanjar.weixin.cp.config.impl.WxCpJedisConfigImpl; import org.apache.commons.lang3.StringUtils; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; import org.noear.solon.core.AppContext; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig; /** * 自动装配基于 jedis 策略配置 * * @author yl * created on 2023/04/23 */ @Configuration @Condition( onProperty = "${"+WxCpProperties.PREFIX + ".configStorage.type} = jedis", onClass = JedisPool.class ) @RequiredArgsConstructor public class WxCpInJedisConfigStorageConfiguration extends AbstractWxCpConfigStorageConfiguration { private final WxCpProperties wxCpProperties; private final AppContext applicationContext; @Bean @Condition(onMissingBean=WxCpConfigStorage.class) public WxCpConfigStorage wxCpConfigStorage() { WxCpDefaultConfigImpl config = getConfigStorage(); return this.config(config, wxCpProperties); } private WxCpJedisConfigImpl getConfigStorage() { WxCpRedisProperties wxCpRedisProperties = wxCpProperties.getConfigStorage().getRedis(); JedisPool jedisPool; if (wxCpRedisProperties != null && StringUtils.isNotEmpty(wxCpRedisProperties.getHost())) { jedisPool = getJedisPool(); } else { jedisPool = applicationContext.getBean(JedisPool.class); } return new WxCpJedisConfigImpl(jedisPool, wxCpProperties.getConfigStorage().getKeyPrefix()); } private JedisPool getJedisPool() { WxCpProperties.ConfigStorage storage = wxCpProperties.getConfigStorage(); WxCpRedisProperties redis = storage.getRedis(); JedisPoolConfig config = new JedisPoolConfig(); if (redis.getMaxActive() != null) { config.setMaxTotal(redis.getMaxActive()); } if (redis.getMaxIdle() != null) { config.setMaxIdle(redis.getMaxIdle()); } if (redis.getMaxWaitMillis() != null) { config.setMaxWaitMillis(redis.getMaxWaitMillis()); } if (redis.getMinIdle() != null) { config.setMinIdle(redis.getMinIdle()); } config.setTestOnBorrow(true); config.setTestWhileIdle(true); return new JedisPool(config, redis.getHost(), redis.getPort(), redis.getTimeout(), redis.getPassword(), redis.getDatabase()); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/integration/WxCpPluginImpl.java
solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/integration/WxCpPluginImpl.java
package com.binarywang.solon.wxjava.cp.integration; import com.binarywang.solon.wxjava.cp.config.WxCpServiceAutoConfiguration; import com.binarywang.solon.wxjava.cp.properties.WxCpProperties; import com.binarywang.solon.wxjava.cp.storage.WxCpInJedisConfigStorageConfiguration; import com.binarywang.solon.wxjava.cp.storage.WxCpInMemoryConfigStorageConfiguration; import com.binarywang.solon.wxjava.cp.storage.WxCpInRedissonConfigStorageConfiguration; import org.noear.solon.core.AppContext; import org.noear.solon.core.Plugin; /** * @author noear 2024/9/2 created */ public class WxCpPluginImpl implements Plugin { @Override public void start(AppContext context) throws Throwable { context.beanMake(WxCpProperties.class); context.beanMake(WxCpServiceAutoConfiguration.class); context.beanMake(WxCpInMemoryConfigStorageConfiguration.class); context.beanMake(WxCpInJedisConfigStorageConfiguration.class); context.beanMake(WxCpInRedissonConfigStorageConfiguration.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/properties/WxCpProperties.java
solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/properties/WxCpProperties.java
package com.binarywang.solon.wxjava.cp.properties; import lombok.Data; import lombok.NoArgsConstructor; import org.noear.solon.annotation.Configuration; import org.noear.solon.annotation.Inject; import java.io.Serializable; /** * 企业微信接入相关配置属性 * * @author yl * created on 2021/12/6 */ @Data @NoArgsConstructor @Configuration @Inject("${" + WxCpProperties.PREFIX + "}") public class WxCpProperties { public static final String PREFIX = "wx.cp"; /** * 微信企业号 corpId */ private String corpId; /** * 微信企业号 corpSecret */ private String corpSecret; /** * 微信企业号应用 token */ private String token; /** * 微信企业号应用 ID */ private Integer agentId; /** * 微信企业号应用 EncodingAESKey */ private String aesKey; /** * 微信企业号应用 会话存档私钥 */ private String msgAuditPriKey; /** * 微信企业号应用 会话存档类库路径 */ private String msgAuditLibPath; /** * 配置存储策略,默认内存 */ private ConfigStorage configStorage = new ConfigStorage(); @Data @NoArgsConstructor public static class ConfigStorage implements Serializable { private static final long serialVersionUID = 4815731027000065434L; /** * 存储类型 */ private StorageType type = StorageType.memory; /** * 指定key前缀 */ private String keyPrefix = "wx:cp"; /** * redis连接配置 */ private WxCpRedisProperties redis = new WxCpRedisProperties(); /** * http代理主机 */ private String httpProxyHost; /** * http代理端口 */ private Integer httpProxyPort; /** * http代理用户名 */ private String httpProxyUsername; /** * http代理密码 */ private String httpProxyPassword; /** * http 请求最大重试次数 * <pre> * {@link me.chanjar.weixin.cp.api.WxCpService#setMaxRetryTimes(int)} * {@link me.chanjar.weixin.cp.api.impl.BaseWxCpServiceImpl#setMaxRetryTimes(int)} * </pre> */ private int maxRetryTimes = 5; /** * http 请求重试间隔 * <pre> * {@link me.chanjar.weixin.cp.api.WxCpService#setRetrySleepMillis(int)} * {@link me.chanjar.weixin.cp.api.impl.BaseWxCpServiceImpl#setRetrySleepMillis(int)} * </pre> */ private int retrySleepMillis = 1000; } public enum StorageType { /** * 内存 */ memory, /** * jedis */ jedis, /** * redisson */ redisson, /** * redistemplate */ redistemplate } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/properties/WxCpRedisProperties.java
solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/properties/WxCpRedisProperties.java
package com.binarywang.solon.wxjava.cp.properties; import lombok.Data; import java.io.Serializable; /** * Redis配置. * * @author yl * created on 2023/04/23 */ @Data public class WxCpRedisProperties implements Serializable { private static final long serialVersionUID = -5924815351660074401L; /** * 主机地址. */ private String host; /** * 端口号. */ private int port = 6379; /** * 密码. */ private String password; /** * 超时. */ private int timeout = 2000; /** * 数据库. */ private int database = 0; private Integer maxActive; private Integer maxIdle; private Integer maxWaitMillis; private Integer minIdle; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/config/WxCpServiceAutoConfiguration.java
solon-plugins/wx-java-cp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/cp/config/WxCpServiceAutoConfiguration.java
package com.binarywang.solon.wxjava.cp.config; import com.binarywang.solon.wxjava.cp.properties.WxCpProperties; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl; import me.chanjar.weixin.cp.config.WxCpConfigStorage; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; /** * 企业微信平台相关服务自动注册 * * @author yl * created on 2021/12/6 */ @Configuration @RequiredArgsConstructor public class WxCpServiceAutoConfiguration { private final WxCpProperties wxCpProperties; @Bean @Condition(onMissingBean = WxCpService.class, onBean = WxCpConfigStorage.class) public WxCpService wxCpService(WxCpConfigStorage wxCpConfigStorage) { WxCpService wxCpService = new WxCpServiceImpl(); wxCpService.setWxCpConfigStorage(wxCpConfigStorage); WxCpProperties.ConfigStorage storage = wxCpProperties.getConfigStorage(); int maxRetryTimes = storage.getMaxRetryTimes(); if (maxRetryTimes < 0) { maxRetryTimes = 0; } int retrySleepMillis = storage.getRetrySleepMillis(); if (retrySleepMillis < 0) { retrySleepMillis = 1000; } wxCpService.setRetrySleepMillis(retrySleepMillis); wxCpService.setMaxRetryTimes(maxRetryTimes); return wxCpService; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-multi-solon-plugin/src/test/java/features/test/LoadTest.java
solon-plugins/wx-java-channel-multi-solon-plugin/src/test/java/features/test/LoadTest.java
package features.test; import org.junit.jupiter.api.Test; import org.noear.solon.test.SolonTest; /** * @author noear 2024/9/4 created */ @SolonTest public class LoadTest { @Test public void load(){ } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/service/WxChannelMultiServicesImpl.java
solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/service/WxChannelMultiServicesImpl.java
package com.binarywang.solon.wxjava.channel.service; import me.chanjar.weixin.channel.api.WxChannelService; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** * 视频号 {@link WxChannelMultiServices} 实现 * * @author <a href="https://github.com/Winnie-by996">Winnie</a> * @date 2024/9/13 */ public class WxChannelMultiServicesImpl implements WxChannelMultiServices { private final Map<String, WxChannelService> services = new ConcurrentHashMap<>(); @Override public WxChannelService getWxChannelService(String tenantId) { return this.services.get(tenantId); } /** * 根据租户 Id,添加一个 WxChannelService 到列表 * * @param tenantId 租户 Id * @param wxChannelService WxChannelService 实例 */ public void addWxChannelService(String tenantId, WxChannelService wxChannelService) { this.services.put(tenantId, wxChannelService); } @Override public void removeWxChannelService(String tenantId) { this.services.remove(tenantId); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/service/WxChannelMultiServices.java
solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/service/WxChannelMultiServices.java
package com.binarywang.solon.wxjava.channel.service; import me.chanjar.weixin.channel.api.WxChannelService; /** * 视频号 {@link WxChannelService} 所有实例存放类. * * @author <a href="https://github.com/Winnie-by996">Winnie</a> * @date 2024/9/13 */ public interface WxChannelMultiServices { /** * 通过租户 Id 获取 WxChannelService * * @param tenantId 租户 Id * @return WxChannelService */ WxChannelService getWxChannelService(String tenantId); /** * 根据租户 Id,从列表中移除一个 WxChannelService 实例 * * @param tenantId 租户 Id */ void removeWxChannelService(String tenantId); }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/integration/WxChannelMultiPluginImpl.java
solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/integration/WxChannelMultiPluginImpl.java
package com.binarywang.solon.wxjava.channel.integration; import com.binarywang.solon.wxjava.channel.configuration.services.WxChannelInJedisConfiguration; import com.binarywang.solon.wxjava.channel.configuration.services.WxChannelInMemoryConfiguration; import com.binarywang.solon.wxjava.channel.configuration.services.WxChannelInRedissonConfiguration; import com.binarywang.solon.wxjava.channel.properties.WxChannelMultiProperties; import org.noear.solon.core.AppContext; import org.noear.solon.core.Plugin; /** * 微信视频号自动注册 * * @author <a href="https://github.com/Winnie-by996">Winnie</a> 2024/9/13 * @author noear 2024/10/9 created */ public class WxChannelMultiPluginImpl implements Plugin { @Override public void start(AppContext context) throws Throwable { context.beanMake(WxChannelMultiProperties.class); context.beanMake(WxChannelInJedisConfiguration.class); context.beanMake(WxChannelInMemoryConfiguration.class); context.beanMake(WxChannelInRedissonConfiguration.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/configuration/services/WxChannelInRedissonConfiguration.java
solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/configuration/services/WxChannelInRedissonConfiguration.java
package com.binarywang.solon.wxjava.channel.configuration.services; import com.binarywang.solon.wxjava.channel.properties.WxChannelMultiProperties; import com.binarywang.solon.wxjava.channel.properties.WxChannelMultiRedisProperties; import com.binarywang.solon.wxjava.channel.service.WxChannelMultiServices; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.channel.config.impl.WxChannelDefaultConfigImpl; import me.chanjar.weixin.channel.config.impl.WxChannelRedissonConfigImpl; import org.apache.commons.lang3.StringUtils; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; import org.noear.solon.core.AppContext; import org.redisson.Redisson; import org.redisson.api.RedissonClient; import org.redisson.config.Config; import org.redisson.config.TransportMode; /** * 自动装配基于 redisson 策略配置 * * @author <a href="https://github.com/Winnie-by996">Winnie</a> 2024/9/13 * @author noear */ @Configuration @Condition( onProperty = "${"+WxChannelMultiProperties.PREFIX + ".configStorage.type} = redisson", onClass = Redisson.class ) @RequiredArgsConstructor public class WxChannelInRedissonConfiguration extends AbstractWxChannelConfiguration { private final WxChannelMultiProperties wxChannelMultiProperties; private final AppContext applicationContext; @Bean public WxChannelMultiServices wxChannelMultiServices() { return this.wxChannelMultiServices(wxChannelMultiProperties); } @Override protected WxChannelDefaultConfigImpl wxChannelConfigStorage(WxChannelMultiProperties wxChannelMultiProperties) { return this.configRedisson(wxChannelMultiProperties); } private WxChannelDefaultConfigImpl configRedisson(WxChannelMultiProperties wxChannelMultiProperties) { WxChannelMultiRedisProperties redisProperties = wxChannelMultiProperties.getConfigStorage().getRedis(); RedissonClient redissonClient; if (redisProperties != null && StringUtils.isNotEmpty(redisProperties.getHost())) { redissonClient = getRedissonClient(wxChannelMultiProperties); } else { redissonClient = applicationContext.getBean(RedissonClient.class); } return new WxChannelRedissonConfigImpl(redissonClient, wxChannelMultiProperties.getConfigStorage().getKeyPrefix()); } private RedissonClient getRedissonClient(WxChannelMultiProperties wxChannelMultiProperties) { WxChannelMultiProperties.ConfigStorage storage = wxChannelMultiProperties.getConfigStorage(); WxChannelMultiRedisProperties redis = storage.getRedis(); Config config = new Config(); config.useSingleServer().setAddress("redis://" + redis.getHost() + ":" + redis.getPort()).setDatabase(redis.getDatabase()).setPassword(redis.getPassword()); config.setTransportMode(TransportMode.NIO); return Redisson.create(config); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/configuration/services/WxChannelInMemoryConfiguration.java
solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/configuration/services/WxChannelInMemoryConfiguration.java
package com.binarywang.solon.wxjava.channel.configuration.services; import com.binarywang.solon.wxjava.channel.properties.WxChannelMultiProperties; import com.binarywang.solon.wxjava.channel.service.WxChannelMultiServices; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.channel.config.impl.WxChannelDefaultConfigImpl; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; import redis.clients.jedis.JedisPool; /** * 自动装配基于内存策略配置 * * @author <a href="https://github.com/Winnie-by996">Winnie</a> 2024/9/13 * @author noear */ @Configuration @Condition( onProperty = "${"+WxChannelMultiProperties.PREFIX + ".configStorage.type} = memory", onClass = JedisPool.class ) @RequiredArgsConstructor public class WxChannelInMemoryConfiguration extends AbstractWxChannelConfiguration { private final WxChannelMultiProperties wxChannelMultiProperties; @Bean public WxChannelMultiServices wxChannelMultiServices() { return this.wxChannelMultiServices(wxChannelMultiProperties); } @Override protected WxChannelDefaultConfigImpl wxChannelConfigStorage(WxChannelMultiProperties wxChannelMultiProperties) { return this.configInMemory(); } private WxChannelDefaultConfigImpl configInMemory() { return new WxChannelDefaultConfigImpl(); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/configuration/services/WxChannelInJedisConfiguration.java
solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/configuration/services/WxChannelInJedisConfiguration.java
package com.binarywang.solon.wxjava.channel.configuration.services; import com.binarywang.solon.wxjava.channel.properties.WxChannelMultiProperties; import com.binarywang.solon.wxjava.channel.properties.WxChannelMultiRedisProperties; import com.binarywang.solon.wxjava.channel.service.WxChannelMultiServices; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.channel.config.impl.WxChannelDefaultConfigImpl; import me.chanjar.weixin.channel.config.impl.WxChannelRedisConfigImpl; import me.chanjar.weixin.common.redis.JedisWxRedisOps; import org.apache.commons.lang3.StringUtils; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; import org.noear.solon.core.AppContext; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig; /** * 自动装配基于 jedis 策略配置 * * @author <a href="https://github.com/Winnie-by996">Winnie</a> 2024/9/13 * @author noear */ @Configuration @Condition( onProperty = "${"+WxChannelMultiProperties.PREFIX + ".configStorage.type} = jedis", onClass = JedisPool.class ) @RequiredArgsConstructor public class WxChannelInJedisConfiguration extends AbstractWxChannelConfiguration { private final WxChannelMultiProperties wxChannelMultiProperties; private final AppContext applicationContext; @Bean public WxChannelMultiServices wxChannelMultiServices() { return this.wxChannelMultiServices(wxChannelMultiProperties); } @Override protected WxChannelDefaultConfigImpl wxChannelConfigStorage(WxChannelMultiProperties wxChannelMultiProperties) { return this.configRedis(wxChannelMultiProperties); } private WxChannelDefaultConfigImpl configRedis(WxChannelMultiProperties wxChannelMultiProperties) { WxChannelMultiRedisProperties wxChannelMultiRedisProperties = wxChannelMultiProperties.getConfigStorage().getRedis(); JedisPool jedisPool; if (wxChannelMultiRedisProperties != null && StringUtils.isNotEmpty(wxChannelMultiRedisProperties.getHost())) { jedisPool = getJedisPool(wxChannelMultiProperties); } else { jedisPool = applicationContext.getBean(JedisPool.class); } return new WxChannelRedisConfigImpl(new JedisWxRedisOps(jedisPool), wxChannelMultiProperties.getConfigStorage().getKeyPrefix()); } private JedisPool getJedisPool(WxChannelMultiProperties wxChannelMultiProperties) { WxChannelMultiProperties.ConfigStorage storage = wxChannelMultiProperties.getConfigStorage(); WxChannelMultiRedisProperties redis = storage.getRedis(); JedisPoolConfig config = new JedisPoolConfig(); if (redis.getMaxActive() != null) { config.setMaxTotal(redis.getMaxActive()); } if (redis.getMaxIdle() != null) { config.setMaxIdle(redis.getMaxIdle()); } if (redis.getMaxWaitMillis() != null) { config.setMaxWaitMillis(redis.getMaxWaitMillis()); } if (redis.getMinIdle() != null) { config.setMinIdle(redis.getMinIdle()); } config.setTestOnBorrow(true); config.setTestWhileIdle(true); return new JedisPool(config, redis.getHost(), redis.getPort(), redis.getTimeout(), redis.getPassword(), redis.getDatabase()); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/configuration/services/AbstractWxChannelConfiguration.java
solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/configuration/services/AbstractWxChannelConfiguration.java
package com.binarywang.solon.wxjava.channel.configuration.services; import com.binarywang.solon.wxjava.channel.enums.HttpClientType; import com.binarywang.solon.wxjava.channel.properties.WxChannelMultiProperties; import com.binarywang.solon.wxjava.channel.properties.WxChannelSingleProperties; import com.binarywang.solon.wxjava.channel.service.WxChannelMultiServices; import com.binarywang.solon.wxjava.channel.service.WxChannelMultiServicesImpl; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.channel.api.WxChannelService; import me.chanjar.weixin.channel.api.impl.WxChannelServiceHttpComponentsImpl; import me.chanjar.weixin.channel.api.impl.WxChannelServiceHttpClientImpl; import me.chanjar.weixin.channel.api.impl.WxChannelServiceImpl; import me.chanjar.weixin.channel.config.WxChannelConfig; import me.chanjar.weixin.channel.config.impl.WxChannelDefaultConfigImpl; import org.apache.commons.lang3.StringUtils; import java.util.Collection; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; /** * WxChannelConfigStorage 抽象配置类 * * @author <a href="https://github.com/Winnie-by996">Winnie</a> 2024/9/13 * @author noear */ @RequiredArgsConstructor @Slf4j public abstract class AbstractWxChannelConfiguration { protected WxChannelMultiServices wxChannelMultiServices(WxChannelMultiProperties wxChannelMultiProperties) { Map<String, WxChannelSingleProperties> appsMap = wxChannelMultiProperties.getApps(); if (appsMap == null || appsMap.isEmpty()) { log.warn("微信视频号应用参数未配置,通过 WxChannelMultiServices#getWxChannelService(\"tenantId\")获取实例将返回空"); return new WxChannelMultiServicesImpl(); } /** * 校验 appId 是否唯一,避免使用 redis 缓存 token、ticket 时错乱。 * * 查看 {@link me.chanjar.weixin.channel.config.impl.WxChannelRedisConfigImpl#setAppid(String)} */ Collection<WxChannelSingleProperties> apps = appsMap.values(); if (apps.size() > 1) { // 校验 appId 是否唯一 boolean multi = apps.stream() // 没有 appId,如果不判断是否为空,这里会报 NPE 异常 .collect(Collectors.groupingBy(c -> c.getAppId() == null ? 0 : c.getAppId(), Collectors.counting())) .entrySet().stream().anyMatch(e -> e.getValue() > 1); if (multi) { throw new RuntimeException("请确保微信视频号配置 appId 的唯一性"); } } WxChannelMultiServicesImpl services = new WxChannelMultiServicesImpl(); Set<Map.Entry<String, WxChannelSingleProperties>> entries = appsMap.entrySet(); for (Map.Entry<String, WxChannelSingleProperties> entry : entries) { String tenantId = entry.getKey(); WxChannelSingleProperties wxChannelSingleProperties = entry.getValue(); WxChannelDefaultConfigImpl storage = this.wxChannelConfigStorage(wxChannelMultiProperties); this.configApp(storage, wxChannelSingleProperties); this.configHttp(storage, wxChannelMultiProperties.getConfigStorage()); WxChannelService wxChannelService = this.wxChannelService(storage, wxChannelMultiProperties); services.addWxChannelService(tenantId, wxChannelService); } return services; } /** * 配置 WxChannelDefaultConfigImpl * * @param wxChannelMultiProperties 参数 * @return WxChannelDefaultConfigImpl */ protected abstract WxChannelDefaultConfigImpl wxChannelConfigStorage(WxChannelMultiProperties wxChannelMultiProperties); public WxChannelService wxChannelService(WxChannelConfig wxChannelConfig, WxChannelMultiProperties wxChannelMultiProperties) { WxChannelMultiProperties.ConfigStorage storage = wxChannelMultiProperties.getConfigStorage(); HttpClientType httpClientType = storage.getHttpClientType(); WxChannelService wxChannelService; switch (httpClientType) { // case OK_HTTP: // wxChannelService = new WxChannelServiceOkHttpImpl(false, false); // break; case HTTP_CLIENT: wxChannelService = new WxChannelServiceHttpClientImpl(); break; case HTTP_COMPONENTS: wxChannelService = new WxChannelServiceHttpComponentsImpl(); break; default: wxChannelService = new WxChannelServiceImpl(); break; } wxChannelService.setConfig(wxChannelConfig); int maxRetryTimes = storage.getMaxRetryTimes(); if (maxRetryTimes < 0) { maxRetryTimes = 0; } int retrySleepMillis = storage.getRetrySleepMillis(); if (retrySleepMillis < 0) { retrySleepMillis = 1000; } wxChannelService.setRetrySleepMillis(retrySleepMillis); wxChannelService.setMaxRetryTimes(maxRetryTimes); return wxChannelService; } private void configApp(WxChannelDefaultConfigImpl config, WxChannelSingleProperties wxChannelSingleProperties) { String appId = wxChannelSingleProperties.getAppId(); String appSecret = wxChannelSingleProperties.getSecret(); String token = wxChannelSingleProperties.getToken(); String aesKey = wxChannelSingleProperties.getAesKey(); boolean useStableAccessToken = wxChannelSingleProperties.isUseStableAccessToken(); config.setAppid(appId); config.setSecret(appSecret); if (StringUtils.isNotBlank(token)) { config.setToken(token); } if (StringUtils.isNotBlank(aesKey)) { config.setAesKey(aesKey); } config.setStableAccessToken(useStableAccessToken); } private void configHttp(WxChannelDefaultConfigImpl config, WxChannelMultiProperties.ConfigStorage storage) { String httpProxyHost = storage.getHttpProxyHost(); Integer httpProxyPort = storage.getHttpProxyPort(); String httpProxyUsername = storage.getHttpProxyUsername(); String httpProxyPassword = storage.getHttpProxyPassword(); if (StringUtils.isNotBlank(httpProxyHost)) { config.setHttpProxyHost(httpProxyHost); if (httpProxyPort != null) { config.setHttpProxyPort(httpProxyPort); } if (StringUtils.isNotBlank(httpProxyUsername)) { config.setHttpProxyUsername(httpProxyUsername); } if (StringUtils.isNotBlank(httpProxyPassword)) { config.setHttpProxyPassword(httpProxyPassword); } } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/properties/WxChannelMultiProperties.java
solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/properties/WxChannelMultiProperties.java
package com.binarywang.solon.wxjava.channel.properties; import com.binarywang.solon.wxjava.channel.enums.HttpClientType; import com.binarywang.solon.wxjava.channel.enums.StorageType; import lombok.Data; import lombok.NoArgsConstructor; import org.noear.solon.annotation.Configuration; import org.noear.solon.annotation.Inject; import java.io.Serializable; import java.util.HashMap; import java.util.Map; /** * 微信多视频号接入相关配置属性 * * @author <a href="https://github.com/Winnie-by996">Winnie</a> * @date 2024/9/13 */ @Data @NoArgsConstructor @Configuration @Inject("${" + WxChannelMultiProperties.PREFIX +"}") public class WxChannelMultiProperties implements Serializable { private static final long serialVersionUID = - 8361973118805546037L; public static final String PREFIX = "wx.channel"; private Map<String, WxChannelSingleProperties> apps = new HashMap<>(); /** * 存储策略 */ private final ConfigStorage configStorage = new ConfigStorage(); @Data @NoArgsConstructor public static class ConfigStorage implements Serializable { private static final long serialVersionUID = - 5152619132544179942L; /** * 存储类型. */ private StorageType type = StorageType.MEMORY; /** * 指定key前缀. */ private String keyPrefix = "wx:channel:multi"; /** * redis连接配置. */ private final WxChannelMultiRedisProperties redis = new WxChannelMultiRedisProperties(); /** * http客户端类型. */ private HttpClientType httpClientType = HttpClientType.HTTP_CLIENT; /** * http代理主机. */ private String httpProxyHost; /** * http代理端口. */ private Integer httpProxyPort; /** * http代理用户名. */ private String httpProxyUsername; /** * http代理密码. */ private String httpProxyPassword; /** * http 请求最大重试次数 * * <p>{@link me.chanjar.weixin.channel.api.WxChannelService#setMaxRetryTimes(int)}</p> * <p>{@link me.chanjar.weixin.channel.api.impl.BaseWxChannelServiceImpl#setMaxRetryTimes(int)}</p> */ private int maxRetryTimes = 5; /** * http 请求重试间隔 * * <p>{@link me.chanjar.weixin.channel.api.WxChannelService#setRetrySleepMillis(int)}</p> * <p>{@link me.chanjar.weixin.channel.api.impl.BaseWxChannelServiceImpl#setRetrySleepMillis(int)}</p> */ private int retrySleepMillis = 1000; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/properties/WxChannelSingleProperties.java
solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/properties/WxChannelSingleProperties.java
package com.binarywang.solon.wxjava.channel.properties; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * 微信视频号相关配置属性 * * @author <a href="https://github.com/Winnie-by996">Winnie</a> * @date 2024/9/13 */ @Data @NoArgsConstructor public class WxChannelSingleProperties implements Serializable { private static final long serialVersionUID = 5306630351265124825L; /** * 设置微信视频号的 appid. */ private String appId; /** * 设置微信视频号的 secret. */ private String secret; /** * 设置微信视频号的 token. */ private String token; /** * 设置微信视频号的 EncodingAESKey. */ private String aesKey; /** * 是否使用稳定版 Access Token */ private boolean useStableAccessToken = false; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/properties/WxChannelMultiRedisProperties.java
solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/properties/WxChannelMultiRedisProperties.java
package com.binarywang.solon.wxjava.channel.properties; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * Redis配置 * * @author <a href="https://github.com/Winnie-by996">Winnie</a> * @date 2024/9/13 */ @Data @NoArgsConstructor public class WxChannelMultiRedisProperties implements Serializable { private static final long serialVersionUID = 9061055444734277357L; /** * 主机地址. */ private String host = "127.0.0.1"; /** * 端口号. */ private int port = 6379; /** * 密码. */ private String password; /** * 超时. */ private int timeout = 2000; /** * 数据库. */ private int database = 0; /** * 最大活动连接数 */ private Integer maxActive; /** * 最大空闲连接数 */ private Integer maxIdle; /** * 最小空闲连接数 */ private Integer minIdle; /** * 最大等待时间 */ private Integer maxWaitMillis; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/enums/HttpClientType.java
solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/enums/HttpClientType.java
package com.binarywang.solon.wxjava.channel.enums; /** * httpclient类型 * * @author <a href="https://github.com/Winnie-by996">Winnie</a> * @date 2024/9/13 */ public enum HttpClientType { /** * HttpClient */ HTTP_CLIENT, /** * HttpComponents */ HTTP_COMPONENTS // WxChannelServiceOkHttpImpl 实现经测试无法正常完成业务固暂不支持OK_HTTP方式 // /** // * OkHttp. // */ // OK_HTTP, }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/enums/StorageType.java
solon-plugins/wx-java-channel-multi-solon-plugin/src/main/java/com/binarywang/solon/wxjava/channel/enums/StorageType.java
package com.binarywang.solon.wxjava.channel.enums; /** * storage类型 * * @author <a href="https://github.com/Winnie-by996">Winnie</a> * @date 2024/9/13 */ public enum StorageType { /** * 内存 */ MEMORY, /** * redis(JedisClient) */ JEDIS, /** * redis(Redisson) */ REDISSON, /** * redis(RedisTemplate) */ REDIS_TEMPLATE }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-open-solon-plugin/src/test/java/features/test/LoadTest.java
solon-plugins/wx-java-open-solon-plugin/src/test/java/features/test/LoadTest.java
package features.test; import org.junit.jupiter.api.Test; import org.noear.solon.test.SolonTest; /** * @author noear 2024/9/4 created */ @SolonTest public class LoadTest { @Test public void load(){ } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/integration/WxOpenPluginImpl.java
solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/integration/WxOpenPluginImpl.java
package com.binarywang.solon.wxjava.open.integration; import com.binarywang.solon.wxjava.open.config.WxOpenServiceAutoConfiguration; import com.binarywang.solon.wxjava.open.config.storage.WxOpenInJedisConfigStorageConfiguration; import com.binarywang.solon.wxjava.open.config.storage.WxOpenInMemoryConfigStorageConfiguration; import com.binarywang.solon.wxjava.open.config.storage.WxOpenInRedissonConfigStorageConfiguration; import com.binarywang.solon.wxjava.open.properties.WxOpenProperties; import org.noear.solon.core.AppContext; import org.noear.solon.core.Plugin; /** * @author noear 2024/9/2 created */ public class WxOpenPluginImpl implements Plugin { @Override public void start(AppContext context) throws Throwable { context.beanMake(WxOpenProperties.class); context.beanMake(WxOpenServiceAutoConfiguration.class); context.beanMake(WxOpenInMemoryConfigStorageConfiguration.class); context.beanMake(WxOpenInJedisConfigStorageConfiguration.class); context.beanMake(WxOpenInRedissonConfigStorageConfiguration.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/properties/WxOpenProperties.java
solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/properties/WxOpenProperties.java
package com.binarywang.solon.wxjava.open.properties; import lombok.Data; import org.noear.solon.annotation.Configuration; import org.noear.solon.annotation.Inject; import java.io.Serializable; import static com.binarywang.solon.wxjava.open.properties.WxOpenProperties.PREFIX; import static com.binarywang.solon.wxjava.open.properties.WxOpenProperties.StorageType.memory; /** * 微信接入相关配置属性. * * @author someone */ @Data @Configuration @Inject("${"+PREFIX+"}") public class WxOpenProperties { public static final String PREFIX = "wx.open"; /** * 设置微信开放平台的appid. */ private String appId; /** * 设置微信开放平台的app secret. */ private String secret; /** * 设置微信开放平台的token. */ private String token; /** * 设置微信开放平台的EncodingAESKey. */ private String aesKey; /** * 存储策略. */ private ConfigStorage configStorage = new ConfigStorage(); @Data public static class ConfigStorage implements Serializable { private static final long serialVersionUID = 4815731027000065434L; /** * 存储类型. */ private StorageType type = memory; /** * 指定key前缀. */ private String keyPrefix = "wx:open"; /** * redis连接配置. */ private WxOpenRedisProperties redis = new WxOpenRedisProperties(); /** * http客户端类型. */ private HttpClientType httpClientType = HttpClientType.httpclient; /** * http代理主机. */ private String httpProxyHost; /** * http代理端口. */ private Integer httpProxyPort; /** * http代理用户名. */ private String httpProxyUsername; /** * http代理密码. */ private String httpProxyPassword; /** * http 请求重试间隔 * <pre> * {@link me.chanjar.weixin.mp.api.impl.BaseWxMpServiceImpl#setRetrySleepMillis(int)} * {@link cn.binarywang.wx.miniapp.api.impl.BaseWxMaServiceImpl#setRetrySleepMillis(int)} * </pre> */ private int retrySleepMillis = 1000; /** * http 请求最大重试次数 * <pre> * {@link me.chanjar.weixin.mp.api.impl.BaseWxMpServiceImpl#setMaxRetryTimes(int)} * {@link cn.binarywang.wx.miniapp.api.impl.BaseWxMaServiceImpl#setMaxRetryTimes(int)} * </pre> */ private int maxRetryTimes = 5; } public enum StorageType { /** * 内存. */ memory, /** * jedis. */ jedis, /** * redisson. */ redisson, /** * redistemplate */ redistemplate } public enum HttpClientType { /** * HttpClient. */ httpclient } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/properties/WxOpenRedisProperties.java
solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/properties/WxOpenRedisProperties.java
package com.binarywang.solon.wxjava.open.properties; import lombok.Data; import java.io.Serializable; /** * Redis配置. * * @author someone */ @Data public class WxOpenRedisProperties implements Serializable { private static final long serialVersionUID = -5924815351660074401L; /** * 主机地址. */ private String host; /** * 端口号. */ private int port = 6379; /** * 密码. */ private String password; /** * 超时. */ private int timeout = 2000; /** * 数据库. */ private int database = 0; private Integer maxActive; private Integer maxIdle; private Integer maxWaitMillis; private Integer minIdle; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/config/WxOpenServiceAutoConfiguration.java
solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/config/WxOpenServiceAutoConfiguration.java
package com.binarywang.solon.wxjava.open.config; import me.chanjar.weixin.open.api.WxOpenComponentService; import me.chanjar.weixin.open.api.WxOpenConfigStorage; import me.chanjar.weixin.open.api.WxOpenService; import me.chanjar.weixin.open.api.impl.WxOpenMessageRouter; import me.chanjar.weixin.open.api.impl.WxOpenServiceImpl; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; /** * 微信开放平台相关服务自动注册. * * @author someone */ @Configuration public class WxOpenServiceAutoConfiguration { @Bean @Condition(onMissingBean = WxOpenService.class, onBean = WxOpenConfigStorage.class) public WxOpenService wxOpenService(WxOpenConfigStorage wxOpenConfigStorage) { WxOpenService wxOpenService = new WxOpenServiceImpl(); wxOpenService.setWxOpenConfigStorage(wxOpenConfigStorage); return wxOpenService; } @Bean public WxOpenMessageRouter wxOpenMessageRouter(WxOpenService wxOpenService) { return new WxOpenMessageRouter(wxOpenService); } @Bean public WxOpenComponentService wxOpenComponentService(WxOpenService wxOpenService) { return wxOpenService.getWxOpenComponentService(); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/config/storage/WxOpenInMemoryConfigStorageConfiguration.java
solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/config/storage/WxOpenInMemoryConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.open.config.storage; import com.binarywang.solon.wxjava.open.properties.WxOpenProperties; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.open.api.WxOpenConfigStorage; import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; /** * @author yl */ @Configuration @Condition( onProperty = "${"+WxOpenProperties.PREFIX + ".configStorage.type:memory} = memory" ) @RequiredArgsConstructor public class WxOpenInMemoryConfigStorageConfiguration extends AbstractWxOpenConfigStorageConfiguration { private final WxOpenProperties properties; @Bean @Condition(onMissingBean=WxOpenConfigStorage.class) public WxOpenConfigStorage wxOpenConfigStorage() { WxOpenInMemoryConfigStorage config = new WxOpenInMemoryConfigStorage(); return this.config(config, properties); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/config/storage/AbstractWxOpenConfigStorageConfiguration.java
solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/config/storage/AbstractWxOpenConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.open.config.storage; import com.binarywang.solon.wxjava.open.properties.WxOpenProperties; import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage; /** * @author yl */ public abstract class AbstractWxOpenConfigStorageConfiguration { protected WxOpenInMemoryConfigStorage config(WxOpenInMemoryConfigStorage config, WxOpenProperties properties) { WxOpenProperties.ConfigStorage storage = properties.getConfigStorage(); config.setWxOpenInfo(properties.getAppId(), properties.getSecret(), properties.getToken(), properties.getAesKey()); config.setHttpProxyHost(storage.getHttpProxyHost()); config.setHttpProxyUsername(storage.getHttpProxyUsername()); config.setHttpProxyPassword(storage.getHttpProxyPassword()); Integer httpProxyPort = storage.getHttpProxyPort(); if (httpProxyPort != null) { config.setHttpProxyPort(httpProxyPort); } int maxRetryTimes = storage.getMaxRetryTimes(); if (maxRetryTimes < 0) { maxRetryTimes = 0; } int retrySleepMillis = storage.getRetrySleepMillis(); if (retrySleepMillis < 0) { retrySleepMillis = 1000; } config.setRetrySleepMillis(retrySleepMillis); config.setMaxRetryTimes(maxRetryTimes); return config; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/config/storage/WxOpenInJedisConfigStorageConfiguration.java
solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/config/storage/WxOpenInJedisConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.open.config.storage; import com.binarywang.solon.wxjava.open.properties.WxOpenProperties; import com.binarywang.solon.wxjava.open.properties.WxOpenRedisProperties; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.open.api.WxOpenConfigStorage; import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage; import me.chanjar.weixin.open.api.impl.WxOpenInRedisConfigStorage; import org.apache.commons.lang3.StringUtils; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; import org.noear.solon.core.AppContext; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig; /** * @author yl */ @Configuration @Condition( onProperty = "${"+WxOpenProperties.PREFIX + ".configStorage.type} = jedis", onClass = JedisPool.class ) @RequiredArgsConstructor public class WxOpenInJedisConfigStorageConfiguration extends AbstractWxOpenConfigStorageConfiguration { private final WxOpenProperties properties; private final AppContext applicationContext; @Bean @Condition(onMissingBean=WxOpenConfigStorage.class) public WxOpenConfigStorage wxOpenConfigStorage() { WxOpenInMemoryConfigStorage config = getWxOpenInRedisConfigStorage(); return this.config(config, properties); } private WxOpenInRedisConfigStorage getWxOpenInRedisConfigStorage() { WxOpenRedisProperties wxOpenRedisProperties = properties.getConfigStorage().getRedis(); JedisPool jedisPool; if (wxOpenRedisProperties != null && StringUtils.isNotEmpty(wxOpenRedisProperties.getHost())) { jedisPool = getJedisPool(); } else { jedisPool = applicationContext.getBean(JedisPool.class); } return new WxOpenInRedisConfigStorage(jedisPool, properties.getConfigStorage().getKeyPrefix()); } private JedisPool getJedisPool() { WxOpenProperties.ConfigStorage storage = properties.getConfigStorage(); WxOpenRedisProperties redis = storage.getRedis(); JedisPoolConfig config = new JedisPoolConfig(); if (redis.getMaxActive() != null) { config.setMaxTotal(redis.getMaxActive()); } if (redis.getMaxIdle() != null) { config.setMaxIdle(redis.getMaxIdle()); } if (redis.getMaxWaitMillis() != null) { config.setMaxWaitMillis(redis.getMaxWaitMillis()); } if (redis.getMinIdle() != null) { config.setMinIdle(redis.getMinIdle()); } config.setTestOnBorrow(true); config.setTestWhileIdle(true); return new JedisPool(config, redis.getHost(), redis.getPort(), redis.getTimeout(), redis.getPassword(), redis.getDatabase()); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/config/storage/WxOpenInRedissonConfigStorageConfiguration.java
solon-plugins/wx-java-open-solon-plugin/src/main/java/com/binarywang/solon/wxjava/open/config/storage/WxOpenInRedissonConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.open.config.storage; import com.binarywang.solon.wxjava.open.properties.WxOpenProperties; import com.binarywang.solon.wxjava.open.properties.WxOpenRedisProperties; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.open.api.WxOpenConfigStorage; import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage; import me.chanjar.weixin.open.api.impl.WxOpenInRedissonConfigStorage; import org.apache.commons.lang3.StringUtils; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; import org.noear.solon.core.AppContext; import org.redisson.Redisson; import org.redisson.api.RedissonClient; import org.redisson.config.Config; import org.redisson.config.TransportMode; /** * @author yl */ @Configuration @Condition( onProperty = "${"+WxOpenProperties.PREFIX + ".configStorage.type} = redisson", onClass = Redisson.class ) @RequiredArgsConstructor public class WxOpenInRedissonConfigStorageConfiguration extends AbstractWxOpenConfigStorageConfiguration { private final WxOpenProperties properties; private final AppContext applicationContext; @Bean @Condition(onMissingBean=WxOpenConfigStorage.class) public WxOpenConfigStorage wxOpenConfigStorage() { WxOpenInMemoryConfigStorage config = getWxOpenInRedissonConfigStorage(); return this.config(config, properties); } private WxOpenInRedissonConfigStorage getWxOpenInRedissonConfigStorage() { WxOpenRedisProperties wxOpenRedisProperties = properties.getConfigStorage().getRedis(); RedissonClient redissonClient; if (wxOpenRedisProperties != null && StringUtils.isNotEmpty(wxOpenRedisProperties.getHost())) { redissonClient = getRedissonClient(); } else { redissonClient = applicationContext.getBean(RedissonClient.class); } return new WxOpenInRedissonConfigStorage(redissonClient, properties.getConfigStorage().getKeyPrefix()); } private RedissonClient getRedissonClient() { WxOpenProperties.ConfigStorage storage = properties.getConfigStorage(); WxOpenRedisProperties redis = storage.getRedis(); Config config = new Config(); config.useSingleServer() .setAddress("redis://" + redis.getHost() + ":" + redis.getPort()) .setDatabase(redis.getDatabase()) .setPassword(redis.getPassword()); config.setTransportMode(TransportMode.NIO); return Redisson.create(config); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-miniapp-solon-plugin/src/test/java/features/test/LoadTest.java
solon-plugins/wx-java-miniapp-solon-plugin/src/test/java/features/test/LoadTest.java
package features.test; import org.junit.jupiter.api.Test; import org.noear.solon.test.SolonTest; /** * @author noear 2024/9/4 created */ @SolonTest public class LoadTest { @Test public void load(){ } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/integration/WxMiniappPluginImpl.java
solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/integration/WxMiniappPluginImpl.java
package com.binarywang.solon.wxjava.miniapp.integration; import com.binarywang.solon.wxjava.miniapp.config.WxMaServiceAutoConfiguration; import com.binarywang.solon.wxjava.miniapp.config.storage.WxMaInJedisConfigStorageConfiguration; import com.binarywang.solon.wxjava.miniapp.config.storage.WxMaInMemoryConfigStorageConfiguration; import com.binarywang.solon.wxjava.miniapp.config.storage.WxMaInRedissonConfigStorageConfiguration; import com.binarywang.solon.wxjava.miniapp.properties.WxMaProperties; import org.noear.solon.core.AppContext; import org.noear.solon.core.Plugin; /** * @author noear 2024/9/2 created */ public class WxMiniappPluginImpl implements Plugin { @Override public void start(AppContext context) throws Throwable { context.beanMake(WxMaProperties.class); context.beanMake(WxMaServiceAutoConfiguration.class); context.beanMake(WxMaInMemoryConfigStorageConfiguration.class); context.beanMake(WxMaInJedisConfigStorageConfiguration.class); context.beanMake(WxMaInRedissonConfigStorageConfiguration.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/properties/RedisProperties.java
solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/properties/RedisProperties.java
package com.binarywang.solon.wxjava.miniapp.properties; import lombok.Data; /** * redis 配置. * * @author <a href="https://github.com/binarywang">Binary Wang</a> * created on 2020-08-30 */ @Data public class RedisProperties { /** * 主机地址.不填则从solon容器内获取JedisPool */ private String host; /** * 端口号. */ private int port = 6379; /** * 密码. */ private String password; /** * 超时. */ private int timeout = 2000; /** * 数据库. */ private int database = 0; private Integer maxActive; private Integer maxIdle; private Integer maxWaitMillis; private Integer minIdle; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/properties/WxMaProperties.java
solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/properties/WxMaProperties.java
package com.binarywang.solon.wxjava.miniapp.properties; import com.binarywang.solon.wxjava.miniapp.enums.HttpClientType; import com.binarywang.solon.wxjava.miniapp.enums.StorageType; import lombok.Data; import org.noear.solon.annotation.Configuration; import org.noear.solon.annotation.Inject; import static com.binarywang.solon.wxjava.miniapp.properties.WxMaProperties.PREFIX; /** * 属性配置类. * * @author <a href="https://github.com/binarywang">Binary Wang</a> * created on 2019-08-10 */ @Data @Configuration @Inject("${" + PREFIX + "}") public class WxMaProperties { public static final String PREFIX = "wx.miniapp"; /** * 设置微信小程序的appid. */ private String appid; /** * 设置微信小程序的Secret. */ private String secret; /** * 设置微信小程序消息服务器配置的token. */ private String token; /** * 设置微信小程序消息服务器配置的EncodingAESKey. */ private String aesKey; /** * 消息格式,XML或者JSON. */ private String msgDataFormat; /** * 是否使用稳定版 Access Token */ private boolean useStableAccessToken = false; /** * 存储策略 */ private final ConfigStorage configStorage = new ConfigStorage(); @Data public static class ConfigStorage { /** * 存储类型. */ private StorageType type = StorageType.Memory; /** * 指定key前缀. */ private String keyPrefix = "wa"; /** * redis连接配置. */ private final RedisProperties redis = new RedisProperties(); /** * http客户端类型. */ private HttpClientType httpClientType = HttpClientType.HttpClient; /** * http代理主机. */ private String httpProxyHost; /** * http代理端口. */ private Integer httpProxyPort; /** * http代理用户名. */ private String httpProxyUsername; /** * http代理密码. */ private String httpProxyPassword; /** * http 请求重试间隔 * <pre> * {@link cn.binarywang.wx.miniapp.api.impl.BaseWxMaServiceImpl#setRetrySleepMillis(int)} * </pre> */ private int retrySleepMillis = 1000; /** * http 请求最大重试次数 * <pre> * {@link cn.binarywang.wx.miniapp.api.impl.BaseWxMaServiceImpl#setMaxRetryTimes(int)} * </pre> */ private int maxRetryTimes = 5; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/config/WxMaServiceAutoConfiguration.java
solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/config/WxMaServiceAutoConfiguration.java
package com.binarywang.solon.wxjava.miniapp.config; import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.api.impl.WxMaServiceHttpClientImpl; import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; import cn.binarywang.wx.miniapp.api.impl.WxMaServiceJoddHttpImpl; import cn.binarywang.wx.miniapp.api.impl.WxMaServiceOkHttpImpl; import cn.binarywang.wx.miniapp.config.WxMaConfig; import com.binarywang.solon.wxjava.miniapp.enums.HttpClientType; import com.binarywang.solon.wxjava.miniapp.properties.WxMaProperties; import lombok.AllArgsConstructor; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; /** * 微信小程序平台相关服务自动注册. * * @author someone TaoYu */ @Configuration @AllArgsConstructor public class WxMaServiceAutoConfiguration { private final WxMaProperties wxMaProperties; /** * 小程序service. * * @return 小程序service */ @Bean @Condition(onMissingBean=WxMaService.class, onBean=WxMaConfig.class) public WxMaService wxMaService(WxMaConfig wxMaConfig) { HttpClientType httpClientType = wxMaProperties.getConfigStorage().getHttpClientType(); WxMaService wxMaService; switch (httpClientType) { case OkHttp: wxMaService = new WxMaServiceOkHttpImpl(); break; case JoddHttp: wxMaService = new WxMaServiceJoddHttpImpl(); break; case HttpClient: wxMaService = new WxMaServiceHttpClientImpl(); break; default: wxMaService = new WxMaServiceImpl(); break; } wxMaService.setWxMaConfig(wxMaConfig); return wxMaService; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/config/storage/AbstractWxMaConfigStorageConfiguration.java
solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/config/storage/AbstractWxMaConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.miniapp.config.storage; import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; import com.binarywang.solon.wxjava.miniapp.properties.WxMaProperties; import org.apache.commons.lang3.StringUtils; /** * @author yl TaoYu */ public abstract class AbstractWxMaConfigStorageConfiguration { protected WxMaDefaultConfigImpl config(WxMaDefaultConfigImpl config, WxMaProperties properties) { config.setAppid(StringUtils.trimToNull(properties.getAppid())); config.setSecret(StringUtils.trimToNull(properties.getSecret())); config.setToken(StringUtils.trimToNull(properties.getToken())); config.setAesKey(StringUtils.trimToNull(properties.getAesKey())); config.setMsgDataFormat(StringUtils.trimToNull(properties.getMsgDataFormat())); config.useStableAccessToken(properties.isUseStableAccessToken()); WxMaProperties.ConfigStorage configStorageProperties = properties.getConfigStorage(); config.setHttpProxyHost(configStorageProperties.getHttpProxyHost()); config.setHttpProxyUsername(configStorageProperties.getHttpProxyUsername()); config.setHttpProxyPassword(configStorageProperties.getHttpProxyPassword()); if (configStorageProperties.getHttpProxyPort() != null) { config.setHttpProxyPort(configStorageProperties.getHttpProxyPort()); } int maxRetryTimes = configStorageProperties.getMaxRetryTimes(); if (configStorageProperties.getMaxRetryTimes() < 0) { maxRetryTimes = 0; } int retrySleepMillis = configStorageProperties.getRetrySleepMillis(); if (retrySleepMillis < 0) { retrySleepMillis = 1000; } config.setRetrySleepMillis(retrySleepMillis); config.setMaxRetryTimes(maxRetryTimes); return config; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/config/storage/WxMaInMemoryConfigStorageConfiguration.java
solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/config/storage/WxMaInMemoryConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.miniapp.config.storage; import cn.binarywang.wx.miniapp.config.WxMaConfig; import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; import com.binarywang.solon.wxjava.miniapp.properties.WxMaProperties; import lombok.RequiredArgsConstructor; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; /** * @author yl TaoYu */ @Configuration @Condition( onProperty = "${"+WxMaProperties.PREFIX + ".configStorage.type:memory} = memory" ) @RequiredArgsConstructor public class WxMaInMemoryConfigStorageConfiguration extends AbstractWxMaConfigStorageConfiguration { private final WxMaProperties properties; @Bean @Condition(onMissingBean=WxMaConfig.class) public WxMaConfig wxMaConfig() { WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); return this.config(config, properties); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/config/storage/WxMaInJedisConfigStorageConfiguration.java
solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/config/storage/WxMaInJedisConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.miniapp.config.storage; import cn.binarywang.wx.miniapp.config.WxMaConfig; import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl; import com.binarywang.solon.wxjava.miniapp.properties.RedisProperties; import com.binarywang.solon.wxjava.miniapp.properties.WxMaProperties; import lombok.RequiredArgsConstructor; import me.chanjar.weixin.common.redis.JedisWxRedisOps; import me.chanjar.weixin.common.redis.WxRedisOps; import org.apache.commons.lang3.StringUtils; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; import org.noear.solon.core.AppContext; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig; /** * @author yl TaoYu */ @Configuration @Condition( onProperty = "${"+WxMaProperties.PREFIX + ".configStorage.type} = jedis", onClass = JedisPool.class ) @RequiredArgsConstructor public class WxMaInJedisConfigStorageConfiguration extends AbstractWxMaConfigStorageConfiguration { private final WxMaProperties properties; private final AppContext applicationContext; @Bean @Condition(onMissingBean=WxMaConfig.class) public WxMaConfig wxMaConfig() { WxMaRedisBetterConfigImpl config = getWxMaRedisBetterConfigImpl(); return this.config(config, properties); } private WxMaRedisBetterConfigImpl getWxMaRedisBetterConfigImpl() { RedisProperties redisProperties = properties.getConfigStorage().getRedis(); JedisPool jedisPool; if (redisProperties != null && StringUtils.isNotEmpty(redisProperties.getHost())) { jedisPool = getJedisPool(); } else { jedisPool = applicationContext.getBean(JedisPool.class); } WxRedisOps redisOps = new JedisWxRedisOps(jedisPool); return new WxMaRedisBetterConfigImpl(redisOps, properties.getConfigStorage().getKeyPrefix()); } private JedisPool getJedisPool() { WxMaProperties.ConfigStorage storage = properties.getConfigStorage(); RedisProperties redis = storage.getRedis(); JedisPoolConfig config = new JedisPoolConfig(); if (redis.getMaxActive() != null) { config.setMaxTotal(redis.getMaxActive()); } if (redis.getMaxIdle() != null) { config.setMaxIdle(redis.getMaxIdle()); } if (redis.getMaxWaitMillis() != null) { config.setMaxWaitMillis(redis.getMaxWaitMillis()); } if (redis.getMinIdle() != null) { config.setMinIdle(redis.getMinIdle()); } config.setTestOnBorrow(true); config.setTestWhileIdle(true); return new JedisPool(config, redis.getHost(), redis.getPort(), redis.getTimeout(), redis.getPassword(), redis.getDatabase()); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/config/storage/WxMaInRedissonConfigStorageConfiguration.java
solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/config/storage/WxMaInRedissonConfigStorageConfiguration.java
package com.binarywang.solon.wxjava.miniapp.config.storage; import cn.binarywang.wx.miniapp.config.WxMaConfig; import cn.binarywang.wx.miniapp.config.impl.WxMaRedissonConfigImpl; import com.binarywang.solon.wxjava.miniapp.properties.RedisProperties; import com.binarywang.solon.wxjava.miniapp.properties.WxMaProperties; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.noear.solon.annotation.Bean; import org.noear.solon.annotation.Condition; import org.noear.solon.annotation.Configuration; import org.noear.solon.core.AppContext; import org.redisson.Redisson; import org.redisson.api.RedissonClient; import org.redisson.config.Config; import org.redisson.config.TransportMode; /** * @author yl TaoYu */ @Configuration @Condition( onProperty = "${"+WxMaProperties.PREFIX + ".configStorage.type} = redisson", onClass = Redisson.class ) @RequiredArgsConstructor public class WxMaInRedissonConfigStorageConfiguration extends AbstractWxMaConfigStorageConfiguration { private final WxMaProperties properties; private final AppContext applicationContext; @Bean @Condition(onMissingBean=WxMaConfig.class) public WxMaConfig wxMaConfig() { WxMaRedissonConfigImpl config = getWxMaInRedissonConfigStorage(); return this.config(config, properties); } private WxMaRedissonConfigImpl getWxMaInRedissonConfigStorage() { RedisProperties redisProperties = properties.getConfigStorage().getRedis(); RedissonClient redissonClient; if (redisProperties != null && StringUtils.isNotEmpty(redisProperties.getHost())) { redissonClient = getRedissonClient(); } else { redissonClient = applicationContext.getBean(RedissonClient.class); } return new WxMaRedissonConfigImpl(redissonClient, properties.getConfigStorage().getKeyPrefix()); } private RedissonClient getRedissonClient() { WxMaProperties.ConfigStorage storage = properties.getConfigStorage(); RedisProperties redis = storage.getRedis(); Config config = new Config(); config.useSingleServer() .setAddress("redis://" + redis.getHost() + ":" + redis.getPort()) .setDatabase(redis.getDatabase()) .setPassword(redis.getPassword()); config.setTransportMode(TransportMode.NIO); return Redisson.create(config); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/enums/HttpClientType.java
solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/enums/HttpClientType.java
package com.binarywang.solon.wxjava.miniapp.enums; /** * httpclient类型. * * @author <a href="https://github.com/binarywang">Binary Wang</a> * created on 2020-05-25 */ public enum HttpClientType { /** * HttpClient. */ HttpClient, /** * OkHttp. */ OkHttp, /** * JoddHttp. */ JoddHttp, }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/enums/StorageType.java
solon-plugins/wx-java-miniapp-solon-plugin/src/main/java/com/binarywang/solon/wxjava/miniapp/enums/StorageType.java
package com.binarywang.solon.wxjava.miniapp.enums; /** * storage类型. * * @author <a href="https://github.com/binarywang">Binary Wang</a> * created on 2020-05-25 */ public enum StorageType { /** * 内存. */ Memory, /** * redis(JedisClient). */ Jedis, /** * redis(Redisson). */ Redisson, /** * redis(RedisTemplate). */ RedisTemplate }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/solon-plugins/wx-java-miniapp-multi-solon-plugin/src/test/java/features/test/LoadTest.java
solon-plugins/wx-java-miniapp-multi-solon-plugin/src/test/java/features/test/LoadTest.java
package features.test; import org.junit.jupiter.api.Test; import org.noear.solon.test.SolonTest; /** * @author noear 2024/9/4 created */ @SolonTest public class LoadTest { @Test public void load(){ } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false