Ejemplo n.º 1
0
 @ResponseBody
 @RequestMapping("/getUserSystemIds")
 @Permission(systemSn = "privilege", moduleSn = "user", value = PermissionConatant.R)
 public String getUserSystemIds(String userId) {
   List<ICSystem> sy = null;
   UserSystem userSystem = new UserSystem();
   userSystem.setUserId(userId);
   List<UserSystem> list;
   try {
     sy = this.iICSystemService.getAllIcSystem(null);
     if (sy != null && sy.size() > 0) {
       list = this.userSystemDao.getAll(userSystem);
       if (list != null && list.size() > 0) {
         for (UserSystem us : list) {
           for (ICSystem ic : sy) {
             if (us.getSystemId().equals(ic.getId())) {
               ic.setChecked(true);
               break;
             }
           }
         }
       }
     }
   } catch (Exception e) {
     logger.error(e);
   }
   return JsonUtils.toJson(sy);
 }
Ejemplo n.º 2
0
  // 对外提供的登录接口 这个方法暂时不用
  public LoginVo login(
      String username, String password, String companyId, String ip, String systemSn)
      throws Exception {
    LoginVo vo = new LoginVo();
    SessionMap sessionMap = new SessionMap();
    // 1:查询到用户对象
    User user = login(username, password);
    if (user != null) {
      vo.setLoginUser(user);
      vo.setSid(user.getId());
      sessionMap.put(PrivilegeConstant.LOGIN_USER, JsonUtils.toJson(user));
      Set<ACL> acls = (Set<ACL>) aclService.getAclsByUserId(user.getId());
      sessionMap.put(PrivilegeConstant.LOGIN_USER_ACLS, JsonUtils.toJson(acls));
      ICSystem icSystem = icSystemDao.getICSystemBySn(systemSn);
      if (icSystem != null) {
        List<Module> modules = moduleService.getTreeModuleBySystemIdAndAcls(acls, icSystem.getId());
        vo.setModules(modules);
      } else {
        throw new PrivilegeException("系统标示找不到");
      }
      // 插入登录日志
      LoginLog loginLog =
          new LoginLog(ip, user.getId(), user.getUsername(), user.getRealName(), "登录");
      loginLogService.insertLoginLog(loginLog);

      CacheEntity ce =
          new CacheEntity(user.getId(), sessionMap, PrivilegeConstant.SESSION_OUT_TIME);
      CacheListHandler.addCache(user.getId(), ce);
      // redisClientTemplate.setex(user.getId(),
      // PrivilegeConstant.SESSION_OUT_TIME,
      // JsonUtils.toJson(sessionMap));
    }
    return vo;
  }