Esempio n. 1
0
 /**
  * 获取登录类型
  *
  * @param request
  * @return
  */
 public static int getLoginType(HttpServletRequest request) {
   Map<String, Object> userMap = CommonUtil.getSessionUser(request);
   Object oLoginType = userMap.get(Constant.SESSION_UER_LOGIN_TYPE);
   int loginType =
       CommonUtil.notEmptyString(oLoginType) ? Integer.valueOf(oLoginType.toString()) : -1;
   return loginType;
 }
Esempio n. 2
0
 /**
  * 将jsonArray字符串转换成Map对象
  *
  * @param params
  * @return
  * @throws Exception
  */
 public static List<Map<String, Object>> convertJsonArrayStringA2Map(String params)
     throws Exception {
   List<Map<String, Object>> paramsList = new ArrayList<Map<String, Object>>();
   if (CommonUtil.notEmptyString(params)) {
     JSONArray jsonArray = new JSONArray(params);
     int len = jsonArray.length();
     for (int i = 0; i < len; i++) {
       Map<String, Object> map = convertJsonString2Map(jsonArray.getJSONObject(i).toString());
       paramsList.add(map);
     }
   }
   return paramsList;
 }
Esempio n. 3
0
 /**
  * 将json字符串转换成Map对象
  *
  * @param params
  * @return
  * @throws Exception
  */
 public static HashMap<String, Object> convertJsonString2Map(String params) throws Exception {
   HashMap<String, Object> paramsMap = new HashMap<String, Object>();
   if (CommonUtil.notEmptyString(params)) {
     JSONObject jsonObject = new JSONObject(params);
     Iterator it = jsonObject.keys();
     while (it.hasNext()) {
       String key = (String) it.next();
       String value = jsonObject.getString(key);
       if (notEmptyString(value)) {
         paramsMap.put(key, value);
       }
     }
   }
   return paramsMap;
 }
Esempio n. 4
0
 /**
  * 设置部门领导和用户登录后数据权限
  *
  * @param request
  * @param conditions
  */
 public static void setLeadersOrgans(HttpServletRequest request, Map<String, Object> conditions) {
   Map<String, Object> userMap = CommonUtil.getSessionUser(request);
   Object oLoginType = userMap.get(Constant.SESSION_UER_LOGIN_TYPE);
   int loginType =
       CommonUtil.notEmptyString(oLoginType) ? Integer.valueOf(oLoginType.toString()) : -2;
   if (loginType == 2) {
     String leadersOrganId = userMap.get(Constant.SESSION_UER_LOGIN_ORGANS).toString();
     String searchOrgId =
         conditions.get("organ_id") == null ? "" : conditions.get("organ_id").toString();
     String organ_id = CommonUtil.justInFirstString(leadersOrganId, searchOrgId);
     organ_id = CommonUtil.isEmptyString(organ_id) ? "-1" : organ_id;
     conditions.put("organ_id", organ_id);
   } else if (loginType == 3) {
     CommonUtil.setUserId2ParamsMap(conditions, request);
   }
 }
Esempio n. 5
0
 /**
  * 获取登录类型
  *
  * @param request
  * @return -1、异常状态; 0、客户端登录; 1、企业管理员登录; 2、部门领导登录; 3、企业用户个人登录
  */
 public static int loginTypeCode(HttpServletRequest request) {
   String userFromSource = getSessionUserSource(request);
   if (Constant.SESSION_USER_SOURCE_MOBILE.equals(userFromSource)) {
     return Constant.SESSION_UER_LOGIN_TYPE_CLIENT;
   }
   if (userFromSource.equals(Constant.SESSION_USER_SOURCE_WEB)) {
     Map<String, Object> userMap = getSessionUser(request);
     String sessionUserType = userMap.get(Constant.SESSION_USER_TYPE).toString();
     if (sessionUserType.equals(Constant.SESSION_USER_TYPE_TENANT)) {
       return Constant.SESSION_UER_LOGIN_TYPE_ADMIN;
     } else if (sessionUserType.equals(Constant.SESSION_USER_TYPE_USER)) {
       Object oIsLeader = userMap.get("isLeader");
       if (CommonUtil.notEmptyString(oIsLeader) && Boolean.valueOf(oIsLeader.toString())) {
         return Constant.SESSION_UER_LOGIN_TYPE_ORGAN;
       } else {
         return Constant.SESSION_UER_LOGIN_TYPE_USER;
       }
     }
   }
   return Constant.SESSION_UER_LOGIN_TYPE_ERROR;
 }