From 15ca027ec8f2e07ab4c3c5f73c0c90b618d83a8b Mon Sep 17 00:00:00 2001 From: Songrui <1778280163@qq.com> Date: Fri, 29 May 2026 01:42:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20'src/main/java/com/example?= =?UTF-8?q?/datacollect/controller/CrawlerController.java'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CrawlerController.java | 62 ------------------- 1 file changed, 62 deletions(-) delete mode 100644 src/main/java/com/example/datacollect/controller/CrawlerController.java diff --git a/src/main/java/com/example/datacollect/controller/CrawlerController.java b/src/main/java/com/example/datacollect/controller/CrawlerController.java deleted file mode 100644 index 8d3b4d7..0000000 --- a/src/main/java/com/example/datacollect/controller/CrawlerController.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.example.datacollect.controller; - -import com.example.datacollect.command.Command; -import com.example.datacollect.command.CrawlCommand; -import com.example.datacollect.command.ExitCommand; -import com.example.datacollect.command.HelpCommand; -import com.example.datacollect.command.HistoryCommand; -import com.example.datacollect.command.ListCommand; -import com.example.datacollect.model.Article; -import com.example.datacollect.view.ConsoleView; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class CrawlerController { - private final Map commands = new HashMap<>(); - private final ConsoleView view; - private final List
articles; - private final List commandHistory = new ArrayList<>(); - - public CrawlerController(ConsoleView view, List
articles) { - this.view = view; - this.articles = articles; - register(new HelpCommand(view)); - register(new ListCommand(view)); - register(new CrawlCommand(view)); - register(new ExitCommand(view)); - register(new HistoryCommand(view, commandHistory)); - } - - private void register(Command command) { - commands.put(command.getName(), command); - } - - private void registerAlias(String alias, Command command) { - commands.put(alias, command); - } - - public void handle(String input) { - String text = input == null ? "" : input.trim(); - if (text.isEmpty()) { - return; - } - - commandHistory.add(text); - - String[] args = text.split("\\s+"); - String cmdName = args[0].toLowerCase(); - - if ("c".equals(cmdName)) { - cmdName = "crawl"; - } - - Command command = commands.get(cmdName); - if (command == null) { - view.printError("Unknown command: " + cmdName); - return; - } - command.execute(args, articles); - } -}