完善DAO层,重构代码,添加了登录功能,修改了一堆bug,具体见日志

This commit is contained in:
twinkle255 2023-05-07 21:07:58 +08:00
parent 96d55c83c3
commit 1fbd2a6553
16 changed files with 256 additions and 140 deletions

View File

@ -1,7 +1,6 @@
# Homework # Homework
- - - - - -
**Last Update Time : 2023-05-05** **Last Update Time : 2023-05-07 21:06**
日志文件:`log.md` 日志文件:`log.md`
- - - - - -
### 运行方式: ### 运行方式:
@ -12,7 +11,13 @@ src -> main -> java -> example -> App.run()
- `userDAO`和`merchantsDAO`中`update`语句未传参 - `userDAO`和`merchantsDAO`中`update`语句未传参
- 未测试非法数据 - 未测试非法数据
- 已测试NULL值 - 已测试NULL值
- 已测试插入数据库时,空白符和换行符的检测
### 待完成功能 ### 待完成功能
- 感觉好像少了个菜品类,实体类好像还得改,服了 - 感觉好像少了个菜品类,实体类好像还得改,服了
- 联合查询 - 是的,我发现了,这个实体关系是真的乱,现在竟然用户点菜的时候需要自己设置折扣,太离谱了,以后再改叭。。。
- 再加个菜品类上面这个问题估计就解决了
- 订单和菜品DAO层的update功能
- `updata`方法更新指定字段 - `updata`方法更新指定字段
- 用户密码的查询和修改
> 暂时就这样了,力不从心了,以后再改吧呜呜呜~

15
log.md
View File

@ -1,7 +1,22 @@
# Homework # Homework
*网安实训作业* *网安实训作业*
## 2023-05-08-NO.2
**重大更新!**
- 修改了超级无敌多的bug
- 新建订单无法点菜bug
- 点菜模块无法自动计算总价bug
- 还有其它一些小bug不多说了
- 增加了一部分非法值检测
- 增加了用户登录功能
- DAO层操作逻辑修改主要是新建订单部分
- 新加用户操作模块
## 2023-05-07-NO.1 ## 2023-05-07-NO.1
- DAO层完成 - DAO层完成
- 重构代码 - 重构代码
- DAO层方法整合 - DAO层方法整合

View File

@ -17,7 +17,7 @@ public class abstractDAO<T> {
ct = getConnection(); ct = getConnection();
ps = ct.prepareStatement(sql); ps = ct.prepareStatement(sql);
ps.setLong(1, id); ps.setLong(1, id);
flag = ps.executeUpdate(sql); flag = ps.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} finally { } finally {

View File

@ -2,16 +2,13 @@ package dao.specification;
import dao.indentAbstractDAO; import dao.indentAbstractDAO;
import entities.Indent; import entities.Indent;
import entities.Merchants;
import entities.Users;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import view.IndentItemView;
import java.sql.Connection; import java.sql.*;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import static dao.specification.abstractDAO.Delete; import static dao.specification.abstractDAO.Delete;
import static util.SQLDatabaseConnection.close; import static util.SQLDatabaseConnection.close;
@ -26,19 +23,45 @@ public class indentDAO implements indentAbstractDAO {
@Override @Override
public int insert(@NotNull Indent indent) { public int insert(@NotNull Indent indent) {
int flag; int flag;
//@FIXME 这个allPrice总价怎么用SQL跨表求和啊超 //FIXME
String insert_sql = "insert into Indent(userID, merchantsID, allPrice, message, createDate) " + String insert_sql = "insert into Indent(userID, merchantsID,allPrice, message, createDate) " +
"values(?,?,?,?,getdate())"; "values(?,?,0,?,getdate()) ";
String SetAllPrice = "update Indent " +
"set allPrice = (select SUM(finalPrice) " +
"from indentItem where Indent.id = indentItem.indentID group by indentID)" +
"from indentItem where indentID = Indent.id and Indent.id = ?";
String selectID = "select MAX(Indent.id) from Indent";
try { try {
IndentItemView iiv = new IndentItemView();
connection = getConnection(); connection = getConnection();
preparedStatement = connection.prepareStatement(insert_sql); preparedStatement = connection.prepareStatement(insert_sql);
//用户ID
preparedStatement.setLong(1, indent.getUserID().getId());
//商家ID
preparedStatement.setLong(2, indent.getMerchantsID().getId());
//备注
if (indent.getMessage() != null && !Objects.equals(indent.getMessage(), " ")) {
preparedStatement.setString(3, indent.getMessage());
} else {
preparedStatement.setNull(3, Types.NVARCHAR);
}
preparedStatement.setObject(1, indent.getUserID()); flag = preparedStatement.executeUpdate();
preparedStatement.setObject(2, indent.getMerchantsID());
preparedStatement.setFloat(3, indent.getAllPrice());
preparedStatement.setString(4, indent.getMessage());
flag = preparedStatement.executeUpdate(insert_sql); //创建订单中的菜品
preparedStatement = connection.prepareStatement(selectID);
resultSet = preparedStatement.executeQuery();
//新的订单对象获取当前订单ID
indent = new Indent();
while (resultSet.next()) {
indent.setId(resultSet.getLong(1));
iiv.CreateIItem(indent.getId());
}
//更新总价
preparedStatement = connection.prepareStatement(SetAllPrice);
preparedStatement.setLong(1, indent.getId());
preparedStatement.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@ -52,20 +75,6 @@ public class indentDAO implements indentAbstractDAO {
@Override @Override
public int delete(@NotNull Indent indent) { public int delete(@NotNull Indent indent) {
String delete_sql = "delete from Indent where id = ?"; String delete_sql = "delete from Indent where id = ?";
// int flag;
// try {
// connection = getConnection();
// preparedStatement = connection.prepareStatement(delete_sql);
//
// preparedStatement.setLong(1, indent.getId());
//
// flag = preparedStatement.executeUpdate(delete_sql);
//
// } catch (SQLException e) {
// throw new RuntimeException(e);
// } finally {
// close(connection, preparedStatement, resultSet);
// }
return Delete return Delete
(connection, preparedStatement, resultSet, delete_sql, indent.getId()); (connection, preparedStatement, resultSet, delete_sql, indent.getId());
} }
@ -86,7 +95,7 @@ public class indentDAO implements indentAbstractDAO {
preparedStatement.setString(4, indent.getMessage()); preparedStatement.setString(4, indent.getMessage());
preparedStatement.setLong(5, indent.getId()); preparedStatement.setLong(5, indent.getId());
flag = preparedStatement.executeUpdate(update_sql); flag = preparedStatement.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -102,8 +111,7 @@ public class indentDAO implements indentAbstractDAO {
try { try {
connection = getConnection(); connection = getConnection();
preparedStatement = connection.prepareStatement(selectAll_sql); preparedStatement = connection.prepareStatement(selectAll_sql);
resultSet = preparedStatement.executeQuery();
resultSet = preparedStatement.executeQuery(selectAll_sql);
while (resultSet.next()) { while (resultSet.next()) {
indent = new Indent(); indent = new Indent();
@ -129,7 +137,7 @@ public class indentDAO implements indentAbstractDAO {
connection = getConnection(); connection = getConnection();
preparedStatement = connection.prepareStatement(selectID_sql); preparedStatement = connection.prepareStatement(selectID_sql);
preparedStatement.setLong(1, id); preparedStatement.setLong(1, id);
preparedStatement.executeQuery(selectID_sql); resultSet = preparedStatement.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
indent = new Indent(); indent = new Indent();
@ -146,8 +154,13 @@ public class indentDAO implements indentAbstractDAO {
private void SetAttribute(@NotNull Indent indent, @NotNull ResultSet rs) throws SQLException { private void SetAttribute(@NotNull Indent indent, @NotNull ResultSet rs) throws SQLException {
indent.setId(rs.getLong("id")); indent.setId(rs.getLong("id"));
indent.setUserID((Users) rs.getObject("userID"));
indent.setMerchantsID((Merchants) rs.getObject("merchantsID")); //结果集是 Long 型数据
userDAO user = new userDAO();
indent.setUserID(user.searchID(rs.getLong("userID")));
merchantsDAO merchant = new merchantsDAO();
indent.setMerchantsID(merchant.searchID(rs.getLong("merchantsID")));
indent.setAllPrice(rs.getFloat("allPrice")); indent.setAllPrice(rs.getFloat("allPrice"));
indent.setMessage(rs.getString("message")); indent.setMessage(rs.getString("message"));
indent.setCreatedDate(rs.getDate("createDate")); indent.setCreatedDate(rs.getDate("createDate"));

View File

@ -18,11 +18,12 @@ public class indentItemDAO implements indentItemAbstractDAO {
private PreparedStatement preparedStatement = null; private PreparedStatement preparedStatement = null;
private ResultSet resultSet = null; private ResultSet resultSet = null;
//TODO 这里逻辑不对用户点菜的时候不能自己设置折扣可能需要再多一个实体才可以
@Override @Override
public int insert(@NotNull IndentItem IItem) { public int insert(@NotNull IndentItem IItem) {
int flag; int flag;
String insert_sql = "insert into indentItem(name, initialPrice, discount, " + String insert_sql = "insert into indentItem(name, initialPrice, discount, " +
"finalPrice, description, indentID) values (?,?,?,?,?,null)"; "finalPrice, description, indentID) values (?,?,?,?,?,?)";
try { try {
connection = getConnection(); connection = getConnection();
preparedStatement = connection.prepareStatement(insert_sql); preparedStatement = connection.prepareStatement(insert_sql);
@ -30,23 +31,25 @@ public class indentItemDAO implements indentItemAbstractDAO {
preparedStatement.setString(1, IItem.getName()); preparedStatement.setString(1, IItem.getName());
preparedStatement.setFloat(2, IItem.getInitialPrice()); preparedStatement.setFloat(2, IItem.getInitialPrice());
//折扣和折后价null值的判断 //折扣和折后价null值的判断
if (IItem.getDiscount().compareTo(0F) > 0 //折扣和0比较,返回1为合法值 if (IItem.getDiscount().compareTo(0F) > 0) {//折扣和0比较,返回1为合法值
|| !String.valueOf(IItem.getDiscount()).equals(" ")) {
preparedStatement.setFloat(3, IItem.getDiscount()); preparedStatement.setFloat(3, IItem.getDiscount());
IItem.setFinalPrice(IItem.getInitialPrice() * IItem.getDiscount());//计算最终价格 IItem.setFinalPrice(IItem.getInitialPrice() * IItem.getDiscount());//计算最终价格
preparedStatement.setFloat(4, IItem.getFinalPrice()); preparedStatement.setFloat(4, IItem.getFinalPrice());
} else { } else {
preparedStatement.setNull(3, Types.FLOAT); preparedStatement.setNull(3, Types.FLOAT);
preparedStatement.setNull(4, Types.FLOAT); //最终价格等于初始价格
preparedStatement.setFloat(4, IItem.getInitialPrice());
} }
//描述 //描述
if (!IItem.getDescription().equals(" ")) { if (IItem.getDescription() != null && !IItem.getDescription().equals(" ")) {
preparedStatement.setString(5, IItem.getDescription()); preparedStatement.setString(5, IItem.getDescription());
} else { } else {
preparedStatement.setNull(5, Types.NVARCHAR); preparedStatement.setNull(5, Types.NVARCHAR);
} }
//菜单ID
preparedStatement.setObject(6, IItem.getIndentID().getId());
flag = preparedStatement.executeUpdate(insert_sql); flag = preparedStatement.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} finally { } finally {
@ -55,23 +58,10 @@ public class indentItemDAO implements indentItemAbstractDAO {
return flag; return flag;
} }
@Override @Override
public int delete(@NotNull IndentItem IItem) { public int delete(@NotNull IndentItem IItem) {
String delete_sql = "delete from indentItem where id = ?"; String delete_sql = "delete from indentItem where id = ?";
// int flag;
// try {
// connection = getConnection();
// preparedStatement = connection.prepareStatement(delete_sql);
// preparedStatement.setLong(1, item.getId());
// flag = preparedStatement.executeUpdate(delete_sql);
//
// } catch (SQLException e) {
// throw new RuntimeException(e);
// } finally {
// close(connection,preparedStatement,resultSet);
// }
//
// return flag;
return Delete return Delete
(connection, preparedStatement, resultSet, delete_sql, IItem.getId()); (connection, preparedStatement, resultSet, delete_sql, IItem.getId());
} }

View File

@ -57,19 +57,6 @@ public class merchantsDAO implements merchantsAbstractDAO {
@Override @Override
public int delete(@NotNull Merchants merchants) { public int delete(@NotNull Merchants merchants) {
String delete_sql = "delete from Merchants where id = ?"; String delete_sql = "delete from Merchants where id = ?";
// int flag = 0;
// try {
// connection = getConnection();
//
// preparedStatement = connection.prepareStatement(delete_sql);
// preparedStatement.setLong(1, merchants.getId());
//
// flag = preparedStatement.executeUpdate();
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// close(connection, preparedStatement, resultSet);
// }
return Delete return Delete
(connection, preparedStatement, resultSet, delete_sql, merchants.getId()); (connection, preparedStatement, resultSet, delete_sql, merchants.getId());
} }
@ -92,7 +79,7 @@ public class merchantsDAO implements merchantsAbstractDAO {
preparedStatement.setString(4, merchants.getPhoneNumber()); preparedStatement.setString(4, merchants.getPhoneNumber());
preparedStatement.setLong(5, merchants.getId()); preparedStatement.setLong(5, merchants.getId());
flag = preparedStatement.executeUpdate(update_sql); flag = preparedStatement.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -48,19 +48,6 @@ public class userDAO implements userAbstractDAO {
@Override @Override
public int delete(@NotNull Users user) { public int delete(@NotNull Users user) {
String delete_sql = "delete from Users where id=?"; String delete_sql = "delete from Users where id=?";
// int flag;
// try {
// connection = getConnection();
//
// preparedStatement = connection.prepareStatement(delete_sql);
// preparedStatement.setLong(1, users.getId());
//
// flag = preparedStatement.executeUpdate();
// } catch (SQLException e) {
// throw new RuntimeException(e);
// } finally {
// close(connection, preparedStatement, resultSet);
// }
return Delete return Delete
(connection, preparedStatement, resultSet, delete_sql, user.getId()); (connection, preparedStatement, resultSet, delete_sql, user.getId());

View File

@ -11,7 +11,7 @@ public class Indent {
private Float allPrice;//菜品总价 private Float allPrice;//菜品总价
Date createdDate;//订单创建时间 Date createdDate;//订单创建时间
String message;//下单备注 private String message;//下单备注
private Users userID;//外键下单用户ID private Users userID;//外键下单用户ID
private Merchants merchantsID;//外键餐厅ID private Merchants merchantsID;//外键餐厅ID

View File

@ -0,0 +1,48 @@
package entities.dto;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Scanner;
import static util.SQLDatabaseConnection.close;
import static util.SQLDatabaseConnection.getConnection;
import static view.CommonUse.CreateIndent;
public class Login {
static Connection conn = null;
static PreparedStatement ps = null;
static ResultSet rs = null;
public static boolean UserLogin(Long id) {
boolean flag = false;
String sql = "select password from Users where id = ?";
try {
conn = getConnection();
ps = conn.prepareStatement(sql);
ps.setLong(1, id);
rs = ps.executeQuery();
if (!rs.next()) {
//TODO ID输入不正确后重新输入但是这个函数调用的太乱了有点偷懒了有机会改一下
System.out.println("查无此人");
CreateIndent();//跳转到登录选项重新输入ID
}
Scanner reader = new Scanner(System.in);
System.out.println("请输入登录密码:");
String password = reader.nextLine();
while (rs.next()) {
flag = password.equals(rs.getString("password"));
}
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
close(conn, ps, rs);
}
return flag;
}
}

View File

@ -94,5 +94,4 @@ public class Toolset {
return fields; return fields;
} }
} }

View File

@ -0,0 +1,56 @@
package view;
import java.util.Scanner;
import static entities.dto.Login.UserLogin;
//用户日常使用
public class CommonUse {
public void use(int chose) {
switch (chose) {
case 0 -> System.exit(0);
case 1 -> CreateIndent();
}
}
//TODO 这个部分和 Login 有点重合代码可以重构一下
public static void CreateIndent() {
Scanner reader = new Scanner(System.in);
Long userID = null;
System.out.println("请输入你的ID:");
//异常处理
try {
userID = reader.nextLong();
} catch (Exception e) {
System.out.println("你输入的ID不正确!\n你想退出吗(Y/n)");
reader = new Scanner(System.in);
String s = reader.next();
if (s.equals("Y")) {
System.exit(0);
} else {
CreateIndent();
}
}
while (true) {
//密码判断
boolean flag = UserLogin(userID);
if (flag) {
IndentView iv = new IndentView();
iv.CreateIndent(userID);
break;
} else {
System.out.println("你输入的密码不正确~\n你想退出吗(Y/n)");
reader = new Scanner(System.in);
String s = reader.next();
if (s.equals("Y")) {
System.exit(0);
}
}
}
}
}

View File

@ -7,6 +7,7 @@ import entities.IndentItem;
import util.Toolset; import util.Toolset;
import java.util.Date; import java.util.Date;
import java.util.Objects;
import java.util.Scanner; import java.util.Scanner;
public class IndentItemView { public class IndentItemView {
@ -14,34 +15,41 @@ public class IndentItemView {
switch (chose) { switch (chose) {
case 0 -> System.exit(0); case 0 -> System.exit(0);
case 1 -> CreateIItem(); case 1 -> DeleteIItem();
case 2 -> DeleteIItem(); case 2 -> UpdateIItem();
case 3 -> UpdateIItem(); case 3 -> SearchIItem(true);//查询全部
case 4 -> SearchIItem(true);//查询全部 case 4 -> SearchIItem(false);//查询ID
case 5 -> SearchIItem(false);//查询ID
} }
} }
private void CreateIItem() { public void CreateIItem(Long indentID) {
indentItemAbstractDAO DML_insert = new indentItemDAO(); indentItemAbstractDAO DML_insert = new indentItemDAO();
Scanner reader = new Scanner(System.in); Scanner reader = new Scanner(System.in);
IndentItem IItem = new IndentItem(); System.out.println("请输入:菜名|初始价格|折扣|描述 退出请输入end");
System.out.println("请输入:菜名|初始价格|折扣|描述|菜单ID"); int flag = 0;
while (!reader.hasNext("end")) {
IndentItem IItem = new IndentItem();
//菜名 //菜名
IItem.setName(reader.nextLine()); IItem.setName(reader.next());
//初始价格 //初始价格
IItem.setInitialPrice(reader.nextFloat()); IItem.setInitialPrice(reader.nextFloat());
//折扣 //折扣
if (reader.hasNextFloat()) {
IItem.setDiscount(reader.nextFloat()); IItem.setDiscount(reader.nextFloat());
} else {
IItem.setDiscount(-1F);
}
//描述 //描述
if (!reader.hasNext("end") && !Objects.equals(reader.nextLine(), " ")) {
IItem.setDescription(reader.nextLine()); IItem.setDescription(reader.nextLine());
}
//菜单ID //菜单ID
Long indentID = reader.nextLong();
indentDAO indent = new indentDAO(); indentDAO indent = new indentDAO();
IItem.setIndentID(indent.searchID(indentID)); IItem.setIndentID(indent.searchID(indentID));
int flag = DML_insert.insert(IItem); flag += DML_insert.insert(IItem);
}
System.out.println(flag + "行受影响"); System.out.println(flag + "行受影响");
} }

View File

@ -5,45 +5,40 @@ import dao.specification.indentDAO;
import dao.specification.merchantsDAO; import dao.specification.merchantsDAO;
import dao.specification.userDAO; import dao.specification.userDAO;
import entities.Indent; import entities.Indent;
import entities.IndentItem;
import entities.Users; import entities.Users;
import util.Toolset; import util.Toolset;
import java.util.List;
import java.util.Scanner; import java.util.Scanner;
public class IndentView { public class IndentView {
public void IndentDB(int chose) throws IllegalAccessException { public void IndentDB(int chose) throws IllegalAccessException {
//TODO 这个交互有点难搞
switch (chose) { switch (chose) {
case 0 -> System.exit(0); case 0 -> System.exit(0);
case 1 -> CreateIndent(); case 1 -> DeleteIndent();
case 2 -> DeleteIndent(); case 2 -> System.out.println("这个功能还在修复呢,小主先看看其它功能吧~");//UpdateIndent();
case 3 -> UpdateIndent(); case 3 -> SearchIndent(true);//查询全部
case 4 -> SearchIndent(true);//查询全部 case 4 -> SearchIndent(false);//按ID查询
case 5 -> SearchIndent(false);//按ID查询
} }
} }
private void CreateIndent() { public void CreateIndent(Long userID) {
indentAbstractDAO DML_insert = new indentDAO();
Scanner reader = new Scanner(System.in); Scanner reader = new Scanner(System.in);
Indent indent = new Indent(); Indent indent = new Indent();
System.out.println("请输入下单用户id|餐厅id|总价|备注");
System.out.println("请输入下单餐厅id|备注");
//用户 //用户
Long userID = reader.nextLong();
userDAO user = new userDAO(); userDAO user = new userDAO();
indent.setUserID(user.searchID(userID)); indent.setUserID(user.searchID(userID));
//餐厅 //餐厅
Long merchantID = reader.nextLong(); Long merchantID = reader.nextLong();
merchantsDAO merchant = new merchantsDAO(); merchantsDAO merchant = new merchantsDAO();
indent.setMerchantsID(merchant.searchID(merchantID)); indent.setMerchantsID(merchant.searchID(merchantID));
//总价
indent.setAllPrice(reader.nextFloat());
//备注 //备注
indent.setMessage(reader.nextLine()); indent.setMessage(reader.nextLine());
indentAbstractDAO DML_insert = new indentDAO();
int flag = DML_insert.insert(indent); int flag = DML_insert.insert(indent);
System.out.println(flag + "行受影响"); System.out.println(flag + "行受影响");
} }
@ -53,7 +48,7 @@ public class IndentView {
Scanner reader = new Scanner(System.in); Scanner reader = new Scanner(System.in);
Indent indent = new Indent(); Indent indent = new Indent();
System.out.println("请输入你要删除的ID"); System.out.println("请输入你要删除的订单ID");
indent.setId(reader.nextLong()); indent.setId(reader.nextLong());
int flag = DML_delete.delete(indent); int flag = DML_delete.delete(indent);
@ -79,4 +74,5 @@ public class IndentView {
System.out.println(Toolset.table(Indent.class, indent)); System.out.println(Toolset.table(Indent.class, indent));
} }
} }
} }

View File

@ -7,6 +7,7 @@ import util.Toolset;
import java.util.Scanner; import java.util.Scanner;
//商家管理
public class MerchantsView { public class MerchantsView {
//商家数据库操作 //商家数据库操作
protected void merchantsDB(int chose) throws IllegalAccessException { protected void merchantsDB(int chose) throws IllegalAccessException {
@ -14,7 +15,7 @@ public class MerchantsView {
case 0 -> System.exit(0); case 0 -> System.exit(0);
case 1 -> CreateMerchant(); case 1 -> CreateMerchant();
case 2 -> DeleteMerchant(); case 2 -> DeleteMerchant();
case 3 -> UpdateMerchant(); case 3 -> System.out.println("这个功能还在修复呢,小主先看看其它功能吧~");//UpdateMerchant();
case 4 -> SearchMerchant(true);//查询所有 case 4 -> SearchMerchant(true);//查询所有
case 5 -> SearchMerchant(false);//查询ID case 5 -> SearchMerchant(false);//查询ID
} }
@ -44,7 +45,8 @@ public class MerchantsView {
System.out.println(flag + "行受影响"); System.out.println(flag + "行受影响");
} }
private void UpdateMerchant() {//@FIXME update没有传值 //@FIXME update没有传值
private void UpdateMerchant() {
Merchants merchants = new Merchants(); Merchants merchants = new Merchants();
Scanner reader = new Scanner(System.in); Scanner reader = new Scanner(System.in);

View File

@ -7,6 +7,7 @@ import util.Toolset;
import java.util.Scanner; import java.util.Scanner;
//TODO 用户密码查找和修改
public class UserView { public class UserView {
//用户数据库操作 //用户数据库操作
protected void userDB(int chose) throws IllegalAccessException { protected void userDB(int chose) throws IllegalAccessException {
@ -22,7 +23,7 @@ public class UserView {
} }
} }
private void CreateUser() {//@TODO 非换行输入 private void CreateUser() {//TODO 非换行输入
Scanner reader = new Scanner(System.in); Scanner reader = new Scanner(System.in);
userAbstractDAO DML_insert = new userDAO(); userAbstractDAO DML_insert = new userDAO();

View File

@ -10,7 +10,6 @@ public class shellUI {
-----------------后台管理系统--------------- -----------------后台管理系统---------------
------------------------------------------ ------------------------------------------
"""); """);
Chose(); Chose();
} }
@ -18,7 +17,9 @@ public class shellUI {
private static void Chose() throws IllegalAccessException { private static void Chose() throws IllegalAccessException {
System.out.println(""" System.out.println("""
请选择你要进行的功能: 请选择你要进行的功能:
1.商家管理\t2.用户管理\t3.订单管理\t0.退出 1.商家管理\t2.用户管理\t3.订单管理
4.我是用户我要登录\t
0.退出
"""); """);
switch (Toolset.option()) { switch (Toolset.option()) {
@ -28,7 +29,8 @@ public class shellUI {
System.out.println(""" System.out.println("""
请选择你想使用的功能: 请选择你想使用的功能:
1.新建商家\t\t2.删除商家\t\t3.更新信息 1.新建商家\t\t2.删除商家\t\t3.更新信息
4.查询所有商家\t5.根据ID查询商家\t0.退出 4.查询所有商家\t5.根据ID查询商家
0.退出
"""); """);
MerchantsView merchants_view = new MerchantsView(); MerchantsView merchants_view = new MerchantsView();
merchants_view.merchantsDB(Toolset.option()); merchants_view.merchantsDB(Toolset.option());
@ -39,7 +41,8 @@ public class shellUI {
System.out.println(""" System.out.println("""
请选择你想使用的功能: 请选择你想使用的功能:
1.新建用户\t\t2.删除用户\t\t3.更新信息 1.新建用户\t\t2.删除用户\t\t3.更新信息
4.查询所有用户\t5.根据ID查询用户\t0.退出 4.查询所有用户\t5.根据ID查询用户
0.退出
"""); """);
UserView user_view = new UserView(); UserView user_view = new UserView();
user_view.userDB(Toolset.option()); user_view.userDB(Toolset.option());
@ -49,20 +52,26 @@ public class shellUI {
case 3 -> { case 3 -> {
System.out.println(""" System.out.println("""
请选择你想使用的功能: 请选择你想使用的功能:
1.新建订单\t\t2.删除订单\t\t3.更新订单 1.删除订单\t\t2.更新订单
4.查询所有订单\t5.根据ID查询订单\t0.退出 3.查询所有订单\t4.根据ID查询订单
0.退出
"""); """);
IndentView indent_view = new IndentView(); IndentView indent_view = new IndentView();
indent_view.IndentDB(Toolset.option()); indent_view.IndentDB(Toolset.option());
Chose(); Chose();
} }
//订单菜品 //下单
case 4 -> { case 4 -> {
System.out.println("""
请选择你想使用的功能:
1.点菜
0.退出
其它功能还在开发中呢请耐心等待哦~
""");
CommonUse user = new CommonUse();
user.use(Toolset.option());
Chose();
} }
} }
} }
} }