Explorar el Código

修改用户设备信息

zhouxianguang hace 6 años
padre
commit
edd9bff632

+ 39 - 24
rankin-api-web/src/main/java/cn/rankin/apiweb/controller/LoginController.java

@@ -112,26 +112,34 @@ public class LoginController
         loginInfoDTO.setDeviceType(deviceType);
 
         //获取设备型号
+        //获取设备型号
         if ("MOBILE".equals(deviceType))
         {
-            Pattern pattern = Pattern.compile(";\\s?(\\S*?\\s?\\S*?)\\s?(Build)?/");
-            Matcher matcher = pattern.matcher(userAgentStr);
-            String model = null;
-            if (matcher.find())
+            String split[] = userAgentStr.split("Build/");
+
+            if(split!=null || split.length > 0)
             {
-                model = matcher.group(1).trim();
-                loginInfoDTO.setDeviceModel(model);
+                String splitType[] =  split[0].split(";");
+                if(splitType!=null && splitType.length>0)
+                {
+                    loginInfoDTO.setDeviceModel(splitType[splitType.length-1]);
+                }
+
             }
+
         }
         else if ("TABLET".equals(deviceType))
         {
-            Pattern pattern = Pattern.compile(";\\s?(\\S*?\\s?\\S*?)\\s?(Build)?/");
-            Matcher matcher = pattern.matcher(userAgentStr);
-            String model = null;
-            if (matcher.find())
+            String split[] = userAgentStr.split("Build/");
+
+            if(split!=null || split.length > 0)
             {
-                model = matcher.group(1).trim();
-                loginInfoDTO.setDeviceModel(model);
+                String splitType[] =  split[0].split(";");
+                if(splitType!=null && splitType.length>0)
+                {
+                    loginInfoDTO.setDeviceModel(splitType[splitType.length-1]);
+                }
+
             }
         }
         else
@@ -179,24 +187,31 @@ public class LoginController
         //获取设备型号
         if ("MOBILE".equals(deviceType))
         {
-            Pattern pattern = Pattern.compile(";\\s?(\\S*?\\s?\\S*?)\\s?(Build)?/");
-            Matcher matcher = pattern.matcher(userAgentStr);
-            String model = null;
-            if (matcher.find())
+            String split[] = userAgentStr.split("Build/");
+
+            if(split!=null || split.length > 0)
             {
-                model = matcher.group(1).trim();
-                loginInfoDTO.setDeviceModel(model);
+                String splitType[] =  split[0].split(";");
+                if(splitType!=null && splitType.length>0)
+                {
+                    loginInfoDTO.setDeviceModel(splitType[splitType.length-1]);
+                }
+
             }
+
         }
         else if ("TABLET".equals(deviceType))
         {
-            Pattern pattern = Pattern.compile(";\\s?(\\S*?\\s?\\S*?)\\s?(Build)?/");
-            Matcher matcher = pattern.matcher(userAgentStr);
-            String model = null;
-            if (matcher.find())
+            String split[] = userAgentStr.split("Build/");
+
+            if(split!=null || split.length > 0)
             {
-                model = matcher.group(1).trim();
-                loginInfoDTO.setDeviceModel(model);
+                String splitType[] =  split[0].split(";");
+                if(splitType!=null && splitType.length>0)
+                {
+                    loginInfoDTO.setDeviceModel(splitType[splitType.length-1]);
+                }
+
             }
         }
         else