Exemplo n.º 1
0
  /**
   * @param pattern
   * @param method
   * @return
   */
  @Override
  public boolean checkUserPermission(String pattern, RequestMethod method) {
    // 获取用户角色
    Visitor visitor = ThreadContext.getSessionVisitor();
    if (visitor == null) {
      return false;
    }

    String urlPattarn = pattern;
    if (!urlPattarn.endsWith(RoleResourceConstant.URL_SPLITOR)) {
      urlPattarn += RoleResourceConstant.URL_SPLITOR;
    }

    Integer roleId = visitor.getRoleId();

    Map<String, Map<RequestMethod, List<Integer>>> roleResMap = getAllAsMap();
    Map<RequestMethod, List<Integer>> methodMap = roleResMap.get(urlPattarn);
    if (methodMap == null) {
      return false;
    }

    List<Integer> roleIdList = methodMap.get(method);
    if (roleIdList == null) {
      return false;
    }

    if (!roleIdList.contains(roleId)) {
      return false;
    }
    return true;
  }
Exemplo n.º 2
0
  @Override
  public VisitorVo getCurVisitor() {

    Visitor visitor = ThreadContext.getSessionVisitor();
    if (visitor == null) {
      return null;
    }

    VisitorVo visitorVo = new VisitorVo();
    visitorVo.setId(visitor.getId());
    visitorVo.setName(visitor.getLoginUserName());

    return visitorVo;
  }
Exemplo n.º 3
0
  /** @param userId */
  @Override
  @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
  public String addOneAppForUser(Long userId, Long appId) {

    User user = getUser(userId);
    String ownAppIds = user.getOwnApps();
    if (!StringUtils.isBlank(ownAppIds)) {
      ownAppIds = ownAppIds + "," + appId;

    } else {
      ownAppIds = String.valueOf(appId);
    }
    user.setOwnApps(ownAppIds);
    Visitor visitor = ThreadContext.getSessionVisitor();
    visitor.setAppIds(user.getOwnApps());
    userDao.update(user);
    return ownAppIds;
  }