| | |
| | | |
| | | public final static int TYPE_DANGER = 3; |
| | | |
| | | public static int getType(HttpServletRequest request, UserInfo user, String detailSystemId) { |
| | | String ip = getIP(request); |
| | | if (!(ip + "").equalsIgnoreCase(user.getIp())) { |
| | | IPUtil.IPInfo ipInfo = IPUtil.getIPInfo(ip); |
| | | user.setIp(ip); |
| | | |
| | | if (ipInfo != null && !StringUtil.isNullOrEmpty(ipInfo.getCity())) { |
| | | user.setCity(ipInfo.getCity()); |
| | | } |
| | | |
| | | if (ipInfo != null && !StringUtil.isNullOrEmpty(ipInfo.getCountry())) { |
| | | user.setCountry(ipInfo.getCountry()); |
| | | } |
| | | new UserService().updateUserInfo(user); |
| | | } |
| | | |
| | | Map<String, String> map = new DetailSystemConfigService().getConfigAsMap(new DetailSystem(SystemUtil.getDetailSystemId() + ""), SystemUtil.getDefaultVersion()); |
| | | String[] detailsystemIds = new String[]{"1", "2", "3", "4", "5", "6", "14", "12", "20", "11"}; |
| | | for (String d : detailsystemIds) { |
| | | if (detailSystemId.equalsIgnoreCase(d)) { |
| | | String dangers = map.get("danger_city"); |
| | | String[] dangerCitys = dangers.split(","); |
| | | for (String c : dangerCitys) |
| | | if (c.equalsIgnoreCase(user.getCity())) {// 北上广深 |
| | | return TYPE_DANGER_AREA; |
| | | } |
| | | return TYPE_DANGER; |
| | | } |
| | | } |
| | | |
| | | return TYPE_NORMAL; |
| | | } |
| | | |
| | | public static String getIP(HttpServletRequest request) { |
| | | String ip = request.getHeader("x-forwarded-for"); |
| | | if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { |