public User getUserInfo(int kid) {
    int index = 0;
    int i = 0;
    int[] user_id = null;
    String[] messenger_id = null;
    User user = new User();

    // System.out.println("keyword: "+kid);
    try {
      stmt =
          con.prepareStatement(
              "SELECT u.messenger_id, uk.user_id, uk.keyword_id FROM user_keyword as uk JOIN users as u on u.user_id = uk.user_id WHERE keyword_id = ? GROUP BY user_id;");
      stmt.setInt(1, kid);
      stmt.executeQuery();
      rs = stmt.getResultSet();
      rs.last();
      user_id = new int[rs.getRow()];
      messenger_id = new String[rs.getRow()];
      rs.beforeFirst();
      // System.out.println("keyword id: "+kid);
      // System.out.println("total users "+user_id.length);

      while (rs.next()) {
        user_id[index] = rs.getInt("user_id");
        messenger_id[index] = rs.getString("messenger_id");
        //                System.out.println("User found...." + user_id[index]+" and " +
        // messenger_id[index] + " for kid " + kid);
        index++;
      }
      user.setUser_id(user_id);
      user.setMessenger_id(messenger_id);
      user.setKid(kid);

      rs.close();
      stmt.close();
      return user;
    } catch (SQLException ex) {
      return null;
    }
  }
Esempio n. 2
0
 /**
  * 保存一个盘点数
  *
  * @return
  * @throws Exception
  */
 public String addChecking() throws Exception {
   this.setReturnurl(
       request.getContextPath()
           + FILESEPARATOR
           + "checking"
           + FILESEPARATOR
           + "toCheckingPage.action");
   if (warehouse != null && warehouse.getId() != null) {
     warehouse = this.warehouseService.get(Warehouse.class, warehouse.getId());
     if (barcode != null) {
       productInfo = this.productinfoService.findByBaecode(barcode);
       if (productInfo == null) {
         this.setMessage("产品编码有错误");
         return INPUT;
       }
       if (quantity == null) {
         this.setMessage("请输入盘点数量");
         return INPUT;
       }
       User user = (User) request.getSession().getAttribute("user");
       pstock = this.pstockService.findbyBarcodeAndWarehouse(barcode, warehouse.getWname());
       stockChecking = new StockChecking(pstock, productInfo, quantity, warehouse);
       if (user != null) {
         stockChecking.setOperator(user.getUsername());
       }
       this.stockCheckingService.add(stockChecking);
       pstock.setQuantity(quantity); // 更新数量
       this.pstockService.update(pstock);
       return SUCCESS;
     } else {
       this.setMessage("产品编码不能为空!");
       return INPUT;
     }
   } else {
     this.setMessage("产品编码不能为空!");
     return INPUT;
   }
 }
  public String validateUser(String email, String password) {
    try {
      User user = new User();
      SecurityManager securityManager = new SecurityManager();
      user = securityManager.getUser(email);

      if (user.getEmail().equals(email)) {
        if (user.getPassword().equals(password)) {

          if (user.getSystem_password() == 1) {
            return "Logged in User:"******" with password reset";
          } else {
            return "Logged in User:"******"login validation error");
    }

    return "You are not a Valid User";
  }