79 lines
2.4 KiB
Java
79 lines
2.4 KiB
Java
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;
|
||
|
||
import java.util.List;
|
||
import java.util.Scanner;
|
||
|
||
public class IndentView {
|
||
public void IndentDB(int chose) throws IllegalAccessException {
|
||
|
||
switch (chose) {
|
||
case 0 -> System.exit(0);
|
||
case 1 -> DeleteIndent();
|
||
case 2 -> System.out.println("这个功能还在修复呢,小主先看看其它功能吧~");//UpdateIndent();
|
||
case 3 -> SearchIndent(true);//查询全部
|
||
case 4 -> SearchIndent(false);//按ID查询
|
||
}
|
||
}
|
||
|
||
public void CreateIndent(Long userID) {
|
||
Scanner reader = new Scanner(System.in);
|
||
Indent indent = new Indent();
|
||
|
||
System.out.println("请输入:下单餐厅id|备注");
|
||
//用户
|
||
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());
|
||
|
||
indentAbstractDAO DML_insert = new indentDAO();
|
||
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();
|
||
|
||
System.out.println("请输入你要删除的订单ID");
|
||
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));
|
||
}
|
||
}
|
||
|
||
}
|