private String platform() {
Map<String, String> parameterMap = WebUtils.getHttpHeaders(WebUtils.getHttpServletRequest());
String platformType = parameterMap.getOrDefault("sourceType", parameterMap.get("sourcetype"));
log.info("请求头:{}", parameterMap);
if (com.opencloud.common.utils.StringUtils.isNotBlank(platformType)) {
log.info("请求头参数sourceType:{}", platformType);
if (ObjectUtil.equals(platformType, "android") || ObjectUtil.equals(platformType, "ios")) {
return "1";
}
if (ObjectUtil.equals(platformType, "web") || ObjectUtil.equals(platformType, "wxweb")) {
return "3";
}
if (ObjectUtil.equals(platformType, "wxmini")) {
return "2";
}
}
return "3";
}
public static Map<String, String> getHttpHeaders(HttpServletRequest request) {
Map<String, String> map = new LinkedHashMap<>();
if (request != null) {
Enumeration<String> enumeration = request.getHeaderNames();
if (enumeration != null) {
while (enumeration.hasMoreElements()) {
String key = enumeration.nextElement();
String value = request.getHeader(key);
map.put(key, value);
}
}
}
return map;
}