Browse Source

添加根据手机号获取用户接口

wangmh 7 years ago
parent
commit
6fac47bd3d

+ 21 - 0
sso-common/src/main/java/com/uas/sso/util/AccountUtils.java

@@ -1291,4 +1291,25 @@ public class AccountUtils {
         }
         return null;
     }
+
+    public static UserView findUserByMobile(String mobile) throws Exception {
+        String url = AccountConfig.getUserSaveUrl();
+        if (!StringUtils.isEmpty(url)) {
+            url = url + "/info/mobile";
+            ModelMap data = new ModelMap();
+            data.put("mobile", mobile);
+            HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data);
+            if (!res.isSuccess()) {
+                throw new Exception(res.getContent());
+            } else {
+                ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
+                if (!result.isSuccess()) {
+                    throw new Exception(result.getErrMsg());
+                } else if (result.getContent() != null) {
+                    return JSON.parseObject(result.getContent().toString(), UserView.class);
+                }
+            }
+        }
+        return null;
+    }
 }

+ 12 - 0
sso-server/src/main/java/com/uas/sso/controller/UserManagerController.java

@@ -141,6 +141,18 @@ public class UserManagerController extends BaseController {
         return success(userService.findOne(userUU));
     }
 
+    /**
+     * 根据用户手机号查询用户信息
+     * @author wangmh
+     * @date 2018/1/26 14:46
+     * @param mobile 用户手机号
+     * @return 用户信息
+     */
+    @RequestMapping(value = "/info/mobile", method = RequestMethod.GET)
+    public ModelMap findByMobile(@RequestParam String mobile) {
+        return success(userService.findByMobile(mobile));
+    }
+
     /**
      * 用户申请绑定企业
      *