1 changed files with 0 additions and 47 deletions
@ -1,47 +0,0 @@ |
|||||
package com.example.moviecli.command; |
|
||||
|
|
||||
import com.example.moviecli.repository.MovieRepository; |
|
||||
import com.example.moviecli.strategy.MovieStrategyFactory; |
|
||||
import com.example.moviecli.view.ConsoleView; |
|
||||
|
|
||||
public class AutoCommand implements Command { |
|
||||
private final ConsoleView view; |
|
||||
private final MovieStrategyFactory factory; |
|
||||
private final CrawlCommand crawlCommand; |
|
||||
|
|
||||
public AutoCommand(ConsoleView view, MovieStrategyFactory factory) { |
|
||||
this.view = view; |
|
||||
this.factory = factory; |
|
||||
this.crawlCommand = new CrawlCommand(view, factory); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public String getName() { |
|
||||
return "auto"; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void execute(String[] args, MovieRepository repository) { |
|
||||
view.printInfo("开始自动执行预设任务..."); |
|
||||
|
|
||||
// 1. 豆瓣电影 Top250
|
|
||||
crawlCommand.execute(new String[]{"crawl", "https://movie.douban.com/top250"}, repository); |
|
||||
|
|
||||
// 2. 新浪新闻(替代猫眼)
|
|
||||
crawlCommand.execute(new String[]{"crawl", "https://news.sina.com.cn/"}, repository); |
|
||||
|
|
||||
// 3. 豆瓣图书 Top50
|
|
||||
crawlCommand.execute(new String[]{"crawl", "https://book.douban.com/top250"}, repository); |
|
||||
|
|
||||
// 4. 列出所有数据
|
|
||||
new ListCommand(view).execute(new String[]{"list"}, repository); |
|
||||
|
|
||||
// 5. 统计评分分布
|
|
||||
new StatCommand(view).execute(new String[]{"stat"}, repository); |
|
||||
|
|
||||
// 6. 导出全部数据到 movies.csv
|
|
||||
new ExportCommand(view).execute(new String[]{"export"}, repository); |
|
||||
|
|
||||
view.printSuccess("自动任务执行完毕!已生成三个独立 CSV 文件及总文件 movies.csv。"); |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue