liusheng
6 天以前 cc479e6a056785103996cc7ea67dbd5faa3e800e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package com.ruoyi.message.wechat;
 
/**
 * 微信公众号机构级配置(appid / appSecret / 网关地址)。
 * <p>
 * 现状:这些值硬编码在 {@code com.ruoyi.common.enums.WxGZHEnum} 枚举里(丽水市中医院、景宁、湖滨、吴山),
 * 由 {@code WxGZHEnum.getDescByCode(orgid)} 返回一个按固定顺序排列的 List,
 * 调用方靠下标 {@code get(1)/get(2)/get(3)} 取值 —— 这是很脆的写法(一旦某个机构缺 appid,
 * 下标就会整体错位;景宁就是因为 appid 为空导致 {@code size()<4} 被跳过)。
 * <p>
 * 本类把下标语义显式化,避免继续用 List 下标传递。
 */
public class WechatMpConfig {
 
    /**
     * 机构ID
     */
    private String orgid;
 
    /**
     * 公众号 AppID
     */
    private String appid;
 
    /**
     * 公众号 AppSecret(参与签名)
     */
    private String appSecret;
 
    /**
     * 公众号网关地址
     */
    private String address;
 
    /**
     * 是否配置完整(appid/appSecret/address 都不为空)
     */
    public boolean isComplete() {
        return isNotEmpty(appid) && isNotEmpty(appSecret) && isNotEmpty(address);
    }
 
    private static boolean isNotEmpty(String value) {
        return value != null && !value.trim().isEmpty();
    }
 
    public String getOrgid() {
        return orgid;
    }
 
    public void setOrgid(String orgid) {
        this.orgid = orgid;
    }
 
    public String getAppid() {
        return appid;
    }
 
    public void setAppid(String appid) {
        this.appid = appid;
    }
 
    public String getAppSecret() {
        return appSecret;
    }
 
    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }
 
    public String getAddress() {
        return address;
    }
 
    public void setAddress(String address) {
        this.address = address;
    }
 
    @Override
    public String toString() {
        return "WechatMpConfig{orgid='" + orgid + '\''
                + ", appid='" + appid + '\''
                + ", appSecret='" + (appSecret == null ? null : "***") + '\''
                + ", address='" + address + '\''
                + '}';
    }
}