微信后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.8 KiB

package com.ynxbd.wx.pwe;
import com.ynxbd.common.helper.ProperHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import java.util.Arrays;
import java.util.List;
@Slf4j
public class PWEConfig {
public static final String PARTNER_ID;
public static final String PARTNER_SECRET; // 合作方密钥
public static final String HOSPITAL_ID; // 医院ID
public static final String SECRET_KEY; // 私钥
public static final String OPEN_IDS; // openIds
//
public static final boolean IS_DEV;
static {
ProperHelper config = new ProperHelper().read("pwe.properties");
boolean isEnable = config.getBoolean("pwe.is_enable", false);
if (isEnable) {
IS_DEV = config.getBoolean("pwe.is_dev", false);
HOSPITAL_ID = config.getString("pwe.hospital_id");
PARTNER_ID = config.getString("pwe.partner_id");
PARTNER_SECRET = config.getString(IS_DEV ? "pwe.dev.partner_secret" : "pwe.partner_secret");
SECRET_KEY = config.getString(IS_DEV ? "pwe.dev.secret_key" : "pwe.secret_key");
OPEN_IDS = config.getString("pwe.dev.open_ids");
} else {
IS_DEV = false;
HOSPITAL_ID = null;
PARTNER_ID = null;
PARTNER_SECRET = null;
SECRET_KEY = null;
OPEN_IDS = null;
}
if (PARTNER_ID == null || PARTNER_SECRET == null) {
log.error("[预问诊]读取配置文件pwe.properties失败");
}
}
public static boolean hasOpenId(String openid) {
if (ObjectUtils.isEmpty(openid)) {
return false;
}
String openIds = OPEN_IDS == null ? "" : OPEN_IDS;
List<String> openIdList = Arrays.asList(openIds.split(","));
return openIdList.contains(openid);
}
}