eason.qian 7 years ago
parent f1f1a62e31
commit a9e1d653aa

@ -32,7 +32,10 @@ import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine; import org.thymeleaf.spring4.SpringTemplateEngine;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* account service for sign in * account service for sign in
@ -64,14 +67,11 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
@Cacheable(value = ":login:managers:", key = "''+#accountId") @Cacheable(value = ":login:managers:", key = "''+#accountId")
public JSONObject getManager(String accountId) { public JSONObject getManager(String accountId) {
JSONObject manager = managerMapper.findById(accountId); JSONObject manager = managerMapper.findById(accountId);
JSONObject org = null;
if (manager == null) { if (manager == null) {
throw new ForbiddenException("用户不存在或已禁用"); throw new ForbiddenException("用户不存在或已禁用");
} }
if (manager.getInteger("org_id") != null) { if (manager.getInteger("org_id") != null) {
org = orgMapper.findOne(manager.getIntValue("org_id")); manager.put("org", orgMapper.findOne(manager.getIntValue("org_id")));
manager.put("org", org);
manager.put("parent_org_id",org.getIntValue("parent_org_id"));
} }
List<JSONObject> funcs = permissionManager.listUserFunctions(manager.getIntValue("role")); List<JSONObject> funcs = permissionManager.listUserFunctions(manager.getIntValue("role"));
List<String> funcIds = new ArrayList<>(); List<String> funcIds = new ArrayList<>();
@ -90,36 +90,12 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
modules.put(module, mod); modules.put(module, mod);
} }
} }
if(org != null && org.getIntValue("type")==0 && org.getString("parent_org_id") != null){
if(modules.containsKey("org")){
deleteOrgModule(modules,"org");
}
if(modules.containsKey("manager_accounts")){
deleteOrgModule(modules,"manager_accounts");
}
}
if(org != null && org.getIntValue("type")==0 && org.getString("parent_org_id") == null){
if(modules.containsKey("manager_accounts")){
deleteOrgModule(modules,"manager_accounts");
}
}
manager.put("available_func_ids", funcIds); manager.put("available_func_ids", funcIds);
manager.put("available_func_names", funcNames); manager.put("available_func_names", funcNames);
manager.put("modules", modules.values()); manager.put("modules", modules.values());
manager.put("module_names", modules.keySet()); manager.put("module_names", modules.keySet());
return manager; return manager;
} }
private void deleteOrgModule(Map<String, JSONObject> modules,String module){
Iterator iterator = modules.keySet().iterator();
while (iterator.hasNext()) {
String key = (String) iterator.next();
if (module.equals(key)) {
iterator.remove();
modules.remove(key);
}
}
}
@Override @Override
@Cacheable(value = ":login:clients:", key = "''+#accountId") @Cacheable(value = ":login:clients:", key = "''+#accountId")

Loading…
Cancel
Save