You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.6 KiB
46 lines
1.6 KiB
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
// 1. 历史记录管理内部类 (或者保持独立文件)
|
|
// 注意:如果这是单独的文件,这个类不需要 public,或者你可以把它拆出去
|
|
class CommandHistory {
|
|
// 【修正点】补全了缺失的 history 变量定义
|
|
private static final List<String> history = new ArrayList<>();
|
|
|
|
public static void add(String command) {
|
|
history.add(command);
|
|
}
|
|
|
|
public static List<String> getHistory() {
|
|
return history;
|
|
}
|
|
}
|
|
|
|
// 2. 具体的命令实现
|
|
// 【修正点】确保文件名也是 HistoryCommand.java
|
|
public class HistoryCommand implements Command {
|
|
|
|
@Override
|
|
public String getName() {
|
|
return "hist";
|
|
}
|
|
|
|
@Override
|
|
public void execute(String[] args, List<Article> articles) {
|
|
// 1. 记录本次输入
|
|
// 【修正点】去掉了多余的 "delimiter:" 和 "x:" 标记
|
|
String currentInput = String.join(" ", args);
|
|
CommandHistory.add(currentInput);
|
|
|
|
// 2. 打印题目要求的AI审计提示词
|
|
System.out.println("AI 架构审计:将类名发给 AI,指令:");
|
|
System.out.println("\"作为Java架构审计师,请检查我的MVC三层划分是否存在越权行为?\"");
|
|
System.out.println("--------------------------------");
|
|
|
|
// 3. 显示所有历史记录
|
|
System.out.println("历史命令记录:");
|
|
for (String cmd : CommandHistory.getHistory()) {
|
|
System.out.println("- " + cmd);
|
|
}
|
|
}
|
|
}
|