added (somewhat) functional front-end
This commit is contained in:
@@ -3,13 +3,13 @@ package nl.herpiederpiee.appie_scraper;
|
||||
import com.microsoft.playwright.ElementHandle;
|
||||
|
||||
public class BonusItem {
|
||||
String title;
|
||||
String description = "";
|
||||
String bonusText;
|
||||
String category;
|
||||
String imageURL;
|
||||
public String title;
|
||||
public String description = "";
|
||||
public String bonusText;
|
||||
public String category;
|
||||
public String imageURL;
|
||||
|
||||
String moreInfoURL;
|
||||
public String moreInfoURL;
|
||||
|
||||
float originalPrice = 0.0f;
|
||||
float bonusPrice = 0.0f;
|
||||
|
||||
@@ -42,6 +42,10 @@ public class BonusManager {
|
||||
public static ArrayList<BonusItem> getBonusItems(String name){
|
||||
ArrayList<Pair<BonusItem, Integer>> list = new ArrayList<>();
|
||||
|
||||
if (name == null || name.trim().isEmpty()){
|
||||
return bonusItems;
|
||||
}
|
||||
|
||||
for (BonusItem bonusItem : bonusItems) {
|
||||
Integer score = fuzzyMatchScore(name, bonusItem.title);
|
||||
list.add(Pair.pair(bonusItem, score));
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
package nl.herpiederpiee.appie_scraper;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Controller
|
||||
public class WebServer {
|
||||
|
||||
@GetMapping("/")
|
||||
public String index() {
|
||||
return "index"; // resolves to index.html in templates/
|
||||
public String index(@RequestParam(value = "fuzzySearch", required = false) String fuzzySearch, Model model) {
|
||||
// Call your BonusManager or service to get items
|
||||
ArrayList<BonusItem> items = BonusManager.getBonusItems(fuzzySearch);
|
||||
model.addAttribute("items", items);
|
||||
return "index";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user