|
|
@@ -67,6 +67,10 @@ public class AuthService {
|
|
|
* 删除用户路径
|
|
|
*/
|
|
|
private static final String DELETE_USER = "/user/deleteUser";
|
|
|
+ /**
|
|
|
+ * 按TOKEN获取用户详情接口
|
|
|
+ */
|
|
|
+ private static final String USER_CONTENT_BY_TOKEN = "/user/getUserByToken";
|
|
|
|
|
|
/**
|
|
|
* 微信账号用户名前缀
|
|
|
@@ -112,7 +116,7 @@ public class AuthService {
|
|
|
/**
|
|
|
* 响应字段:用户名
|
|
|
*/
|
|
|
- private static final String RESPONSE_FIELD_USERNAME = "username";
|
|
|
+ public static final String RESPONSE_FIELD_USERNAME = "username";
|
|
|
/**
|
|
|
* 相应字段:用户角色Id
|
|
|
*/
|
|
|
@@ -314,10 +318,40 @@ public class AuthService {
|
|
|
return phoneService.sendCode(phone);
|
|
|
}
|
|
|
|
|
|
- public void bindEnterprise(String token, String enterpriseId) {
|
|
|
+ /**
|
|
|
+ * 升级用户为企业用户权限组
|
|
|
+ */
|
|
|
+ public void upgradeRoleEnterprise(JSONObject userContent) {
|
|
|
+ updateRole(userContent, Collections.singletonList("40"), Collections.emptyList(), "11");
|
|
|
+ updateRole(userContent, Collections.singletonList("44"), Collections.emptyList(), "12");
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 降级用户使其失去企业用户权限组
|
|
|
+ */
|
|
|
+ public void deUpgradeRoleEnterprise(JSONObject userContent) {
|
|
|
+ updateRole(userContent, Collections.emptyList(), Collections.singletonList("40"), "11");
|
|
|
+ updateRole(userContent, Collections.emptyList(), Collections.singletonList("44"), "12");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过token获取用户auth信息的content部分
|
|
|
+ * @param token 需要获取信息的用户的token
|
|
|
+ * @return 用户auth接口返回的content部分
|
|
|
+ */
|
|
|
+ public JSONObject getUserContentByToken(String token) {
|
|
|
+ MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
|
|
+ params.add("token", token);
|
|
|
+ params.add("serviceId",0);
|
|
|
+ Map<String, String> header = new HashMap<>();
|
|
|
+ header.put("token", token);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(HttpUtil.requestPost(oauthPath + USER_CONTENT_BY_TOKEN, params, header));
|
|
|
+ if (isSuccess(jsonObject)) {
|
|
|
+ return jsonObject.getJSONObject(RESPONSE_FIELD_CONTENT);
|
|
|
+ }else {
|
|
|
+ throw new RuntimeException(jsonObject.getString(RESPONSE_FIELD_MESSAGE));
|
|
|
+ }
|
|
|
+ }
|
|
|
// ============================ 私有方法 ============================
|
|
|
|
|
|
/**
|
|
|
@@ -386,7 +420,6 @@ public class AuthService {
|
|
|
HttpUtil.requestPost(oauthPath + DELETE_USER, params, header);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 初始化用户数据
|
|
|
*/
|
|
|
@@ -444,29 +477,13 @@ public class AuthService {
|
|
|
* 检查用户账户DMS数据存在性
|
|
|
*/
|
|
|
private JSONObject getUserDmsData(String userCode) {
|
|
|
- List<JSONObject> js = dMSService.getUserJSONByCode(userCode);
|
|
|
+ List<JSONObject> js = dMSService.getUserJSONByCode(userCode,getTokenOfServiceAccount());
|
|
|
if (!js.isEmpty()) {
|
|
|
return js.get(0);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 升级用户为企业用户权限组
|
|
|
- */
|
|
|
- private void upgradeRoleEnterprise(JSONObject userContent) {
|
|
|
- updateRole(userContent, Collections.singletonList("40"), Collections.emptyList(), "11");
|
|
|
- updateRole(userContent, Collections.singletonList("44"), Collections.emptyList(), "12");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 降级用户使其失去企业用户权限组
|
|
|
- */
|
|
|
- private void deUpgradeRoleEnterprise(JSONObject userContent) {
|
|
|
- updateRole(userContent, Collections.emptyList(), Collections.singletonList("40"), "11");
|
|
|
- updateRole(userContent, Collections.emptyList(), Collections.singletonList("44"), "12");
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 尝试注册并初始化用户
|
|
|
*/
|