@Override public Recipe findRecipeIdbyWindowDishname(Window window, String dishname) throws Exception { Recipe recipe = new Recipe(); String sql = "select distinct recipeid from recipe where windowid=? and dishname=?"; this.pstmt = this.conn.prepareStatement(sql); this.pstmt.setInt(1, window.getWindowId()); this.pstmt.setString(2, dishname); ResultSet rs = this.pstmt.executeQuery(); if (rs.next()) { recipe.setRecipeId(rs.getInt(1)); // ********************************************* } // if return recipe; }
@Override public ArrayList<Recipe> findRecipsbyWindowId(int windowid) throws Exception { // 窗口的所有菜系名称和菜的平均分 ArrayList<Recipe> recipes = new ArrayList<Recipe>(); String sql = "select recipeid,windowid,dishname,averagedishscore from recipe where windowid=? order by averagedishscore desc"; this.pstmt = this.conn.prepareStatement(sql); this.pstmt.setInt(1, windowid); ResultSet rs = this.pstmt.executeQuery(); while (rs.next()) { Recipe temprecipe = new Recipe(); temprecipe.setRecipeId(rs.getInt(1)); temprecipe.setWindowId(rs.getInt(2)); temprecipe.setDishname(rs.getString(3)); temprecipe.setAverageDishScore(rs.getDouble(4)); recipes.add(temprecipe); } return recipes; }