2023-05-07 06:29:18 +00:00
|
|
|
|
package view;
|
|
|
|
|
|
|
|
|
|
import dao.indentAbstractDAO;
|
|
|
|
|
import dao.specification.indentDAO;
|
|
|
|
|
import dao.specification.merchantsDAO;
|
|
|
|
|
import dao.specification.userDAO;
|
|
|
|
|
import entities.Indent;
|
|
|
|
|
import entities.Users;
|
|
|
|
|
import util.Toolset;
|
|
|
|
|
|
2023-05-07 13:07:58 +00:00
|
|
|
|
import java.util.List;
|
2023-05-07 06:29:18 +00:00
|
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
|
|
public class IndentView {
|
|
|
|
|
public void IndentDB(int chose) throws IllegalAccessException {
|
|
|
|
|
|
|
|
|
|
switch (chose) {
|
|
|
|
|
case 0 -> System.exit(0);
|
2023-05-07 13:07:58 +00:00
|
|
|
|
case 1 -> DeleteIndent();
|
|
|
|
|
case 2 -> System.out.println("这个功能还在修复呢,小主先看看其它功能吧~");//UpdateIndent();
|
|
|
|
|
case 3 -> SearchIndent(true);//查询全部
|
|
|
|
|
case 4 -> SearchIndent(false);//按ID查询
|
2023-05-07 06:29:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-07 13:07:58 +00:00
|
|
|
|
public void CreateIndent(Long userID) {
|
2023-05-07 06:29:18 +00:00
|
|
|
|
Scanner reader = new Scanner(System.in);
|
|
|
|
|
Indent indent = new Indent();
|
2023-05-07 13:07:58 +00:00
|
|
|
|
|
|
|
|
|
System.out.println("请输入:下单餐厅id|备注");
|
2023-05-07 06:29:18 +00:00
|
|
|
|
//用户
|
|
|
|
|
userDAO user = new userDAO();
|
|
|
|
|
indent.setUserID(user.searchID(userID));
|
|
|
|
|
//餐厅
|
|
|
|
|
Long merchantID = reader.nextLong();
|
|
|
|
|
merchantsDAO merchant = new merchantsDAO();
|
|
|
|
|
indent.setMerchantsID(merchant.searchID(merchantID));
|
|
|
|
|
//备注
|
|
|
|
|
indent.setMessage(reader.nextLine());
|
|
|
|
|
|
2023-05-07 13:07:58 +00:00
|
|
|
|
indentAbstractDAO DML_insert = new indentDAO();
|
2023-05-07 06:29:18 +00:00
|
|
|
|
int flag = DML_insert.insert(indent);
|
|
|
|
|
System.out.println(flag + "行受影响");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DeleteIndent() {
|
|
|
|
|
indentAbstractDAO DML_delete = new indentDAO();
|
|
|
|
|
Scanner reader = new Scanner(System.in);
|
|
|
|
|
Indent indent = new Indent();
|
|
|
|
|
|
2023-05-07 13:07:58 +00:00
|
|
|
|
System.out.println("请输入你要删除的订单ID");
|
2023-05-07 06:29:18 +00:00
|
|
|
|
indent.setId(reader.nextLong());
|
|
|
|
|
|
|
|
|
|
int flag = DML_delete.delete(indent);
|
|
|
|
|
System.out.println(flag + "行受影响");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO 更新订单
|
|
|
|
|
private void UpdateIndent() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SearchIndent(boolean b) throws IllegalAccessException {
|
|
|
|
|
Indent indent = new Indent();
|
|
|
|
|
indentAbstractDAO DQL = new indentDAO();
|
|
|
|
|
Scanner reader = new Scanner(System.in);
|
|
|
|
|
if (b) {//b 为 true 查询全部
|
|
|
|
|
for (Indent item : DQL.search(indent)) {
|
|
|
|
|
System.out.println(Toolset.table(Indent.class, item));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
System.out.println("请输入你要查询的ID:");
|
|
|
|
|
indent = DQL.searchID(reader.nextLong());
|
|
|
|
|
System.out.println(Toolset.table(Indent.class, indent));
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-07 13:07:58 +00:00
|
|
|
|
|
2023-05-07 06:29:18 +00:00
|
|
|
|
}
|