diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/hotelbook-JavaWeb-master.iml b/.idea/hotelbook-JavaWeb-master.iml
new file mode 100644
index 0000000..e986d51
--- /dev/null
+++ b/.idea/hotelbook-JavaWeb-master.iml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
new file mode 100644
index 0000000..125b106
--- /dev/null
+++ b/.idea/libraries/lib.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..1acf042
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..ff1d92c
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..088d39e
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 438ff68..43aac08 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,13 @@
-# hotelbook-JavaWeb-master
+## 酒店管理系统
+> 项目具体说明:简单的酒店管理系统。
+
+### 基础环境:
+
+- Tomcat9
+- Java 1.8+
+- Mysql/Mariadb
+
+### 描述:
+
+很简陋的小项目,真的很简陋,关于部署:Tomcat 务必为 9.X,JDK 可 12;数据库文件位于 `~/src/sql/` 中,初始登录用户密码为:`root`/`toor`;Tomcat 应用上下文为 `/hb`;项目依赖:`lib` 目录。
diff --git a/hotelbook-JavaWeb.iml b/hotelbook-JavaWeb.iml
new file mode 100644
index 0000000..fefe670
--- /dev/null
+++ b/hotelbook-JavaWeb.iml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/base64-1.2.jar b/lib/base64-1.2.jar
new file mode 100644
index 0000000..b152c89
Binary files /dev/null and b/lib/base64-1.2.jar differ
diff --git a/lib/c3p0-0.9.5.2.jar b/lib/c3p0-0.9.5.2.jar
new file mode 100644
index 0000000..579cedd
Binary files /dev/null and b/lib/c3p0-0.9.5.2.jar differ
diff --git a/lib/commons-collections4-4.1.jar b/lib/commons-collections4-4.1.jar
new file mode 100644
index 0000000..43a9413
Binary files /dev/null and b/lib/commons-collections4-4.1.jar differ
diff --git a/lib/commons-fileupload-1.2.1.jar b/lib/commons-fileupload-1.2.1.jar
new file mode 100644
index 0000000..aa209b3
Binary files /dev/null and b/lib/commons-fileupload-1.2.1.jar differ
diff --git a/lib/commons-io-1.4.jar b/lib/commons-io-1.4.jar
new file mode 100644
index 0000000..133dc6c
Binary files /dev/null and b/lib/commons-io-1.4.jar differ
diff --git a/lib/gson-2.2.4.jar b/lib/gson-2.2.4.jar
new file mode 100644
index 0000000..9478253
Binary files /dev/null and b/lib/gson-2.2.4.jar differ
diff --git a/lib/hamcrest-core-1.3.jar b/lib/hamcrest-core-1.3.jar
new file mode 100644
index 0000000..9d5fe16
Binary files /dev/null and b/lib/hamcrest-core-1.3.jar differ
diff --git a/lib/javax.annotation.jar b/lib/javax.annotation.jar
new file mode 100644
index 0000000..52dca7f
Binary files /dev/null and b/lib/javax.annotation.jar differ
diff --git a/lib/javax.ejb.jar b/lib/javax.ejb.jar
new file mode 100644
index 0000000..4ebf5ec
Binary files /dev/null and b/lib/javax.ejb.jar differ
diff --git a/lib/javax.jms.jar b/lib/javax.jms.jar
new file mode 100644
index 0000000..d31451a
Binary files /dev/null and b/lib/javax.jms.jar differ
diff --git a/lib/javax.persistence.jar b/lib/javax.persistence.jar
new file mode 100644
index 0000000..21d80e0
Binary files /dev/null and b/lib/javax.persistence.jar differ
diff --git a/lib/javax.resource.jar b/lib/javax.resource.jar
new file mode 100644
index 0000000..696a234
Binary files /dev/null and b/lib/javax.resource.jar differ
diff --git a/lib/javax.servlet.jar b/lib/javax.servlet.jar
new file mode 100644
index 0000000..0519e4a
Binary files /dev/null and b/lib/javax.servlet.jar differ
diff --git a/lib/javax.servlet.jsp.jar b/lib/javax.servlet.jsp.jar
new file mode 100644
index 0000000..9c0631c
Binary files /dev/null and b/lib/javax.servlet.jsp.jar differ
diff --git a/lib/javax.servlet.jsp.jstl.jar b/lib/javax.servlet.jsp.jstl.jar
new file mode 100644
index 0000000..7be17cc
Binary files /dev/null and b/lib/javax.servlet.jsp.jstl.jar differ
diff --git a/lib/javax.transaction.jar b/lib/javax.transaction.jar
new file mode 100644
index 0000000..729c695
Binary files /dev/null and b/lib/javax.transaction.jar differ
diff --git a/lib/junit-4.12.jar b/lib/junit-4.12.jar
new file mode 100644
index 0000000..3a7fc26
Binary files /dev/null and b/lib/junit-4.12.jar differ
diff --git a/lib/mchange-commons-java-0.2.11.jar b/lib/mchange-commons-java-0.2.11.jar
new file mode 100644
index 0000000..88f1d47
Binary files /dev/null and b/lib/mchange-commons-java-0.2.11.jar differ
diff --git a/lib/mysql-connector-java-5.1.44-bin.jar b/lib/mysql-connector-java-5.1.44-bin.jar
new file mode 100644
index 0000000..2f2e32d
Binary files /dev/null and b/lib/mysql-connector-java-5.1.44-bin.jar differ
diff --git a/lib/poi-3.17.jar b/lib/poi-3.17.jar
new file mode 100644
index 0000000..353ce76
Binary files /dev/null and b/lib/poi-3.17.jar differ
diff --git a/lib/poi-examples-3.17.jar b/lib/poi-examples-3.17.jar
new file mode 100644
index 0000000..a923b04
Binary files /dev/null and b/lib/poi-examples-3.17.jar differ
diff --git a/lib/poi-excelant-3.17.jar b/lib/poi-excelant-3.17.jar
new file mode 100644
index 0000000..da9f5ed
Binary files /dev/null and b/lib/poi-excelant-3.17.jar differ
diff --git a/lib/poi-ooxml-3.17.jar b/lib/poi-ooxml-3.17.jar
new file mode 100644
index 0000000..68086e8
Binary files /dev/null and b/lib/poi-ooxml-3.17.jar differ
diff --git a/lib/poi-ooxml-schemas-3.17.jar b/lib/poi-ooxml-schemas-3.17.jar
new file mode 100644
index 0000000..2e9b3e7
Binary files /dev/null and b/lib/poi-ooxml-schemas-3.17.jar differ
diff --git a/lib/poi-scratchpad-3.17.jar b/lib/poi-scratchpad-3.17.jar
new file mode 100644
index 0000000..12ba1f1
Binary files /dev/null and b/lib/poi-scratchpad-3.17.jar differ
diff --git a/lib/xmlbeans-2.6.0.jar b/lib/xmlbeans-2.6.0.jar
new file mode 100644
index 0000000..d1b6627
Binary files /dev/null and b/lib/xmlbeans-2.6.0.jar differ
diff --git a/out/production/main/com/inks/hb/authinfo/controller/AuthInfoExcelServlet.class b/out/production/main/com/inks/hb/authinfo/controller/AuthInfoExcelServlet.class
new file mode 100644
index 0000000..b4d6a27
Binary files /dev/null and b/out/production/main/com/inks/hb/authinfo/controller/AuthInfoExcelServlet.class differ
diff --git a/out/production/main/com/inks/hb/authinfo/controller/AuthInfoServlet.class b/out/production/main/com/inks/hb/authinfo/controller/AuthInfoServlet.class
new file mode 100644
index 0000000..643df65
Binary files /dev/null and b/out/production/main/com/inks/hb/authinfo/controller/AuthInfoServlet.class differ
diff --git a/out/production/main/com/inks/hb/authinfo/dao/AuthInfoDao.class b/out/production/main/com/inks/hb/authinfo/dao/AuthInfoDao.class
new file mode 100644
index 0000000..9971e17
Binary files /dev/null and b/out/production/main/com/inks/hb/authinfo/dao/AuthInfoDao.class differ
diff --git a/out/production/main/com/inks/hb/authinfo/pojo/AuthInfo.class b/out/production/main/com/inks/hb/authinfo/pojo/AuthInfo.class
new file mode 100644
index 0000000..32dd201
Binary files /dev/null and b/out/production/main/com/inks/hb/authinfo/pojo/AuthInfo.class differ
diff --git a/out/production/main/com/inks/hb/authinfo/service/AuthService.class b/out/production/main/com/inks/hb/authinfo/service/AuthService.class
new file mode 100644
index 0000000..b2fd721
Binary files /dev/null and b/out/production/main/com/inks/hb/authinfo/service/AuthService.class differ
diff --git a/out/production/main/com/inks/hb/authinfo/service/AuthServiceImpl.class b/out/production/main/com/inks/hb/authinfo/service/AuthServiceImpl.class
new file mode 100644
index 0000000..dfd67ab
Binary files /dev/null and b/out/production/main/com/inks/hb/authinfo/service/AuthServiceImpl.class differ
diff --git a/out/production/main/com/inks/hb/billinfo/pojo/BillInfo.class b/out/production/main/com/inks/hb/billinfo/pojo/BillInfo.class
new file mode 100644
index 0000000..7d6ba77
Binary files /dev/null and b/out/production/main/com/inks/hb/billinfo/pojo/BillInfo.class differ
diff --git a/out/production/main/com/inks/hb/common/CommonDao.class b/out/production/main/com/inks/hb/common/CommonDao.class
new file mode 100644
index 0000000..49a69b4
Binary files /dev/null and b/out/production/main/com/inks/hb/common/CommonDao.class differ
diff --git a/out/production/main/com/inks/hb/common/CommonFilter.class b/out/production/main/com/inks/hb/common/CommonFilter.class
new file mode 100644
index 0000000..e9a043c
Binary files /dev/null and b/out/production/main/com/inks/hb/common/CommonFilter.class differ
diff --git a/out/production/main/com/inks/hb/common/DBUtil.class b/out/production/main/com/inks/hb/common/DBUtil.class
new file mode 100644
index 0000000..0a0a1da
Binary files /dev/null and b/out/production/main/com/inks/hb/common/DBUtil.class differ
diff --git a/out/production/main/com/inks/hb/common/ExitSystemServlet.class b/out/production/main/com/inks/hb/common/ExitSystemServlet.class
new file mode 100644
index 0000000..1b119c3
Binary files /dev/null and b/out/production/main/com/inks/hb/common/ExitSystemServlet.class differ
diff --git a/out/production/main/com/inks/hb/common/ExportExcel.class b/out/production/main/com/inks/hb/common/ExportExcel.class
new file mode 100644
index 0000000..4626c7d
Binary files /dev/null and b/out/production/main/com/inks/hb/common/ExportExcel.class differ
diff --git a/out/production/main/com/inks/hb/common/MD5.class b/out/production/main/com/inks/hb/common/MD5.class
new file mode 100644
index 0000000..64f65a3
Binary files /dev/null and b/out/production/main/com/inks/hb/common/MD5.class differ
diff --git a/out/production/main/com/inks/hb/common/PojotoGson.class b/out/production/main/com/inks/hb/common/PojotoGson.class
new file mode 100644
index 0000000..6349524
Binary files /dev/null and b/out/production/main/com/inks/hb/common/PojotoGson.class differ
diff --git a/out/production/main/com/inks/hb/floorinfo/controller/FloorInfoExcelServlet.class b/out/production/main/com/inks/hb/floorinfo/controller/FloorInfoExcelServlet.class
new file mode 100644
index 0000000..cfc388a
Binary files /dev/null and b/out/production/main/com/inks/hb/floorinfo/controller/FloorInfoExcelServlet.class differ
diff --git a/out/production/main/com/inks/hb/floorinfo/controller/FloorInfoServlet.class b/out/production/main/com/inks/hb/floorinfo/controller/FloorInfoServlet.class
new file mode 100644
index 0000000..c94018b
Binary files /dev/null and b/out/production/main/com/inks/hb/floorinfo/controller/FloorInfoServlet.class differ
diff --git a/out/production/main/com/inks/hb/floorinfo/controller/QueryFloorNameServlet.class b/out/production/main/com/inks/hb/floorinfo/controller/QueryFloorNameServlet.class
new file mode 100644
index 0000000..99d0ce4
Binary files /dev/null and b/out/production/main/com/inks/hb/floorinfo/controller/QueryFloorNameServlet.class differ
diff --git a/out/production/main/com/inks/hb/floorinfo/dao/FloorInfoDao.class b/out/production/main/com/inks/hb/floorinfo/dao/FloorInfoDao.class
new file mode 100644
index 0000000..05ecd82
Binary files /dev/null and b/out/production/main/com/inks/hb/floorinfo/dao/FloorInfoDao.class differ
diff --git a/out/production/main/com/inks/hb/floorinfo/pojo/FloorInfo.class b/out/production/main/com/inks/hb/floorinfo/pojo/FloorInfo.class
new file mode 100644
index 0000000..ca68f49
Binary files /dev/null and b/out/production/main/com/inks/hb/floorinfo/pojo/FloorInfo.class differ
diff --git a/out/production/main/com/inks/hb/floorinfo/service/FloorInfoService.class b/out/production/main/com/inks/hb/floorinfo/service/FloorInfoService.class
new file mode 100644
index 0000000..fe06410
Binary files /dev/null and b/out/production/main/com/inks/hb/floorinfo/service/FloorInfoService.class differ
diff --git a/out/production/main/com/inks/hb/floorinfo/service/FloorInfoServiceImpl.class b/out/production/main/com/inks/hb/floorinfo/service/FloorInfoServiceImpl.class
new file mode 100644
index 0000000..1e08f39
Binary files /dev/null and b/out/production/main/com/inks/hb/floorinfo/service/FloorInfoServiceImpl.class differ
diff --git a/out/production/main/com/inks/hb/logInfo/controller/LogInfoExcelServlet.class b/out/production/main/com/inks/hb/logInfo/controller/LogInfoExcelServlet.class
new file mode 100644
index 0000000..da6fbab
Binary files /dev/null and b/out/production/main/com/inks/hb/logInfo/controller/LogInfoExcelServlet.class differ
diff --git a/out/production/main/com/inks/hb/logInfo/controller/LogInfoServlet.class b/out/production/main/com/inks/hb/logInfo/controller/LogInfoServlet.class
new file mode 100644
index 0000000..3194fe3
Binary files /dev/null and b/out/production/main/com/inks/hb/logInfo/controller/LogInfoServlet.class differ
diff --git a/out/production/main/com/inks/hb/logInfo/dao/LogInfoDao.class b/out/production/main/com/inks/hb/logInfo/dao/LogInfoDao.class
new file mode 100644
index 0000000..e944365
Binary files /dev/null and b/out/production/main/com/inks/hb/logInfo/dao/LogInfoDao.class differ
diff --git a/out/production/main/com/inks/hb/logInfo/pojo/LogInfo.class b/out/production/main/com/inks/hb/logInfo/pojo/LogInfo.class
new file mode 100644
index 0000000..381b0c6
Binary files /dev/null and b/out/production/main/com/inks/hb/logInfo/pojo/LogInfo.class differ
diff --git a/out/production/main/com/inks/hb/logInfo/service/LogInfoService.class b/out/production/main/com/inks/hb/logInfo/service/LogInfoService.class
new file mode 100644
index 0000000..37fd64d
Binary files /dev/null and b/out/production/main/com/inks/hb/logInfo/service/LogInfoService.class differ
diff --git a/out/production/main/com/inks/hb/logInfo/service/LogInfoServiceImpl.class b/out/production/main/com/inks/hb/logInfo/service/LogInfoServiceImpl.class
new file mode 100644
index 0000000..733adb7
Binary files /dev/null and b/out/production/main/com/inks/hb/logInfo/service/LogInfoServiceImpl.class differ
diff --git a/out/production/main/com/inks/hb/login/controller/InsertLoginServlet.class b/out/production/main/com/inks/hb/login/controller/InsertLoginServlet.class
new file mode 100644
index 0000000..b1f41d5
Binary files /dev/null and b/out/production/main/com/inks/hb/login/controller/InsertLoginServlet.class differ
diff --git a/out/production/main/com/inks/hb/login/controller/LoginExcelServlet.class b/out/production/main/com/inks/hb/login/controller/LoginExcelServlet.class
new file mode 100644
index 0000000..a3f357a
Binary files /dev/null and b/out/production/main/com/inks/hb/login/controller/LoginExcelServlet.class differ
diff --git a/out/production/main/com/inks/hb/login/controller/LoginTableServlet.class b/out/production/main/com/inks/hb/login/controller/LoginTableServlet.class
new file mode 100644
index 0000000..753cd7d
Binary files /dev/null and b/out/production/main/com/inks/hb/login/controller/LoginTableServlet.class differ
diff --git a/out/production/main/com/inks/hb/login/controller/QueryLoginInfoServlet.class b/out/production/main/com/inks/hb/login/controller/QueryLoginInfoServlet.class
new file mode 100644
index 0000000..e3c475d
Binary files /dev/null and b/out/production/main/com/inks/hb/login/controller/QueryLoginInfoServlet.class differ
diff --git a/out/production/main/com/inks/hb/login/controller/QueryLoginNameServlet.class b/out/production/main/com/inks/hb/login/controller/QueryLoginNameServlet.class
new file mode 100644
index 0000000..8491c34
Binary files /dev/null and b/out/production/main/com/inks/hb/login/controller/QueryLoginNameServlet.class differ
diff --git a/out/production/main/com/inks/hb/login/controller/UpdatePwdServlet.class b/out/production/main/com/inks/hb/login/controller/UpdatePwdServlet.class
new file mode 100644
index 0000000..56246d6
Binary files /dev/null and b/out/production/main/com/inks/hb/login/controller/UpdatePwdServlet.class differ
diff --git a/out/production/main/com/inks/hb/login/controller/UploadFileServlet.class b/out/production/main/com/inks/hb/login/controller/UploadFileServlet.class
new file mode 100644
index 0000000..54c7067
Binary files /dev/null and b/out/production/main/com/inks/hb/login/controller/UploadFileServlet.class differ
diff --git a/out/production/main/com/inks/hb/login/dao/LoginDao.class b/out/production/main/com/inks/hb/login/dao/LoginDao.class
new file mode 100644
index 0000000..92f3dba
Binary files /dev/null and b/out/production/main/com/inks/hb/login/dao/LoginDao.class differ
diff --git a/out/production/main/com/inks/hb/login/pojo/Login.class b/out/production/main/com/inks/hb/login/pojo/Login.class
new file mode 100644
index 0000000..8581513
Binary files /dev/null and b/out/production/main/com/inks/hb/login/pojo/Login.class differ
diff --git a/out/production/main/com/inks/hb/login/service/LoginService.class b/out/production/main/com/inks/hb/login/service/LoginService.class
new file mode 100644
index 0000000..6d0a086
Binary files /dev/null and b/out/production/main/com/inks/hb/login/service/LoginService.class differ
diff --git a/out/production/main/com/inks/hb/login/service/LoginServiceImpl.class b/out/production/main/com/inks/hb/login/service/LoginServiceImpl.class
new file mode 100644
index 0000000..bd8d576
Binary files /dev/null and b/out/production/main/com/inks/hb/login/service/LoginServiceImpl.class differ
diff --git a/out/production/main/com/inks/hb/orderinfo/controller/InsertAndUpdateServlet.class b/out/production/main/com/inks/hb/orderinfo/controller/InsertAndUpdateServlet.class
new file mode 100644
index 0000000..f83bf29
Binary files /dev/null and b/out/production/main/com/inks/hb/orderinfo/controller/InsertAndUpdateServlet.class differ
diff --git a/out/production/main/com/inks/hb/orderinfo/controller/OrderInfoExcelServlet.class b/out/production/main/com/inks/hb/orderinfo/controller/OrderInfoExcelServlet.class
new file mode 100644
index 0000000..63e7f40
Binary files /dev/null and b/out/production/main/com/inks/hb/orderinfo/controller/OrderInfoExcelServlet.class differ
diff --git a/out/production/main/com/inks/hb/orderinfo/controller/OrderInfoServlet.class b/out/production/main/com/inks/hb/orderinfo/controller/OrderInfoServlet.class
new file mode 100644
index 0000000..e8bf6c7
Binary files /dev/null and b/out/production/main/com/inks/hb/orderinfo/controller/OrderInfoServlet.class differ
diff --git a/out/production/main/com/inks/hb/orderinfo/controller/QueryOrderInfoServlet.class b/out/production/main/com/inks/hb/orderinfo/controller/QueryOrderInfoServlet.class
new file mode 100644
index 0000000..9bc5ab4
Binary files /dev/null and b/out/production/main/com/inks/hb/orderinfo/controller/QueryOrderInfoServlet.class differ
diff --git a/out/production/main/com/inks/hb/orderinfo/dao/OrderInfoDao.class b/out/production/main/com/inks/hb/orderinfo/dao/OrderInfoDao.class
new file mode 100644
index 0000000..e8aa8de
Binary files /dev/null and b/out/production/main/com/inks/hb/orderinfo/dao/OrderInfoDao.class differ
diff --git a/out/production/main/com/inks/hb/orderinfo/pojo/OrderInfo.class b/out/production/main/com/inks/hb/orderinfo/pojo/OrderInfo.class
new file mode 100644
index 0000000..710629a
Binary files /dev/null and b/out/production/main/com/inks/hb/orderinfo/pojo/OrderInfo.class differ
diff --git a/out/production/main/com/inks/hb/orderinfo/pojo/OrderToTable.class b/out/production/main/com/inks/hb/orderinfo/pojo/OrderToTable.class
new file mode 100644
index 0000000..56563f4
Binary files /dev/null and b/out/production/main/com/inks/hb/orderinfo/pojo/OrderToTable.class differ
diff --git a/out/production/main/com/inks/hb/orderinfo/service/OrderInfoService.class b/out/production/main/com/inks/hb/orderinfo/service/OrderInfoService.class
new file mode 100644
index 0000000..2c6ec0f
Binary files /dev/null and b/out/production/main/com/inks/hb/orderinfo/service/OrderInfoService.class differ
diff --git a/out/production/main/com/inks/hb/orderinfo/service/OrderInfoServiceImpl.class b/out/production/main/com/inks/hb/orderinfo/service/OrderInfoServiceImpl.class
new file mode 100644
index 0000000..31cca4d
Binary files /dev/null and b/out/production/main/com/inks/hb/orderinfo/service/OrderInfoServiceImpl.class differ
diff --git a/out/production/main/com/inks/hb/roomtype/controller/InsertRoomTypeServlet.class b/out/production/main/com/inks/hb/roomtype/controller/InsertRoomTypeServlet.class
new file mode 100644
index 0000000..c46813e
Binary files /dev/null and b/out/production/main/com/inks/hb/roomtype/controller/InsertRoomTypeServlet.class differ
diff --git a/out/production/main/com/inks/hb/roomtype/controller/QueryRoomTypeNameServlet.class b/out/production/main/com/inks/hb/roomtype/controller/QueryRoomTypeNameServlet.class
new file mode 100644
index 0000000..ddc4aa3
Binary files /dev/null and b/out/production/main/com/inks/hb/roomtype/controller/QueryRoomTypeNameServlet.class differ
diff --git a/out/production/main/com/inks/hb/roomtype/controller/RoomInfoExcelServlet.class b/out/production/main/com/inks/hb/roomtype/controller/RoomInfoExcelServlet.class
new file mode 100644
index 0000000..a0ea874
Binary files /dev/null and b/out/production/main/com/inks/hb/roomtype/controller/RoomInfoExcelServlet.class differ
diff --git a/out/production/main/com/inks/hb/roomtype/controller/RoomTypeServlet.class b/out/production/main/com/inks/hb/roomtype/controller/RoomTypeServlet.class
new file mode 100644
index 0000000..764021c
Binary files /dev/null and b/out/production/main/com/inks/hb/roomtype/controller/RoomTypeServlet.class differ
diff --git a/out/production/main/com/inks/hb/roomtype/controller/selectRomeTypeIdServlet.class b/out/production/main/com/inks/hb/roomtype/controller/selectRomeTypeIdServlet.class
new file mode 100644
index 0000000..6dc611c
Binary files /dev/null and b/out/production/main/com/inks/hb/roomtype/controller/selectRomeTypeIdServlet.class differ
diff --git a/out/production/main/com/inks/hb/roomtype/dao/RoomTypeDao.class b/out/production/main/com/inks/hb/roomtype/dao/RoomTypeDao.class
new file mode 100644
index 0000000..5df8073
Binary files /dev/null and b/out/production/main/com/inks/hb/roomtype/dao/RoomTypeDao.class differ
diff --git a/out/production/main/com/inks/hb/roomtype/pojo/RoomType.class b/out/production/main/com/inks/hb/roomtype/pojo/RoomType.class
new file mode 100644
index 0000000..3b0320c
Binary files /dev/null and b/out/production/main/com/inks/hb/roomtype/pojo/RoomType.class differ
diff --git a/out/production/main/com/inks/hb/roomtype/service/RoomTypeService.class b/out/production/main/com/inks/hb/roomtype/service/RoomTypeService.class
new file mode 100644
index 0000000..c1353a1
Binary files /dev/null and b/out/production/main/com/inks/hb/roomtype/service/RoomTypeService.class differ
diff --git a/out/production/main/com/inks/hb/roomtype/service/RoomTypeServiceImpl.class b/out/production/main/com/inks/hb/roomtype/service/RoomTypeServiceImpl.class
new file mode 100644
index 0000000..86f9650
Binary files /dev/null and b/out/production/main/com/inks/hb/roomtype/service/RoomTypeServiceImpl.class differ
diff --git a/out/test/test/com/inks/hb/authinfo/dao/AuthInfoDaoTest.class b/out/test/test/com/inks/hb/authinfo/dao/AuthInfoDaoTest.class
new file mode 100644
index 0000000..a378b9b
Binary files /dev/null and b/out/test/test/com/inks/hb/authinfo/dao/AuthInfoDaoTest.class differ
diff --git a/out/test/test/com/inks/hb/common/ExportExcelTest.class b/out/test/test/com/inks/hb/common/ExportExcelTest.class
new file mode 100644
index 0000000..d731e5c
Binary files /dev/null and b/out/test/test/com/inks/hb/common/ExportExcelTest.class differ
diff --git a/out/test/test/com/inks/hb/common/MD5Test.class b/out/test/test/com/inks/hb/common/MD5Test.class
new file mode 100644
index 0000000..1e59b28
Binary files /dev/null and b/out/test/test/com/inks/hb/common/MD5Test.class differ
diff --git a/out/test/test/com/inks/hb/floorinfo/dao/FloorInfoDaoTest.class b/out/test/test/com/inks/hb/floorinfo/dao/FloorInfoDaoTest.class
new file mode 100644
index 0000000..67b360c
Binary files /dev/null and b/out/test/test/com/inks/hb/floorinfo/dao/FloorInfoDaoTest.class differ
diff --git a/out/test/test/com/inks/hb/login/service/LoginServiceImplTest.class b/out/test/test/com/inks/hb/login/service/LoginServiceImplTest.class
new file mode 100644
index 0000000..c058a62
Binary files /dev/null and b/out/test/test/com/inks/hb/login/service/LoginServiceImplTest.class differ
diff --git a/out/test/test/com/inks/hb/orderinfo/dao/OrderInfoDaoTest.class b/out/test/test/com/inks/hb/orderinfo/dao/OrderInfoDaoTest.class
new file mode 100644
index 0000000..d6216e2
Binary files /dev/null and b/out/test/test/com/inks/hb/orderinfo/dao/OrderInfoDaoTest.class differ
diff --git a/out/test/test/com/inks/hb/orderinfo/service/OrderInfoServiceImplTest.class b/out/test/test/com/inks/hb/orderinfo/service/OrderInfoServiceImplTest.class
new file mode 100644
index 0000000..9b4341a
Binary files /dev/null and b/out/test/test/com/inks/hb/orderinfo/service/OrderInfoServiceImplTest.class differ
diff --git a/src/main/java/com/inks/hb/authinfo/controller/AuthInfoExcelServlet.java b/src/main/java/com/inks/hb/authinfo/controller/AuthInfoExcelServlet.java
new file mode 100644
index 0000000..a258f3d
--- /dev/null
+++ b/src/main/java/com/inks/hb/authinfo/controller/AuthInfoExcelServlet.java
@@ -0,0 +1,38 @@
+package com.inks.hb.authinfo.controller;
+
+import com.inks.hb.authinfo.pojo.AuthInfo;
+import com.inks.hb.authinfo.service.AuthService;
+import com.inks.hb.authinfo.service.AuthServiceImpl;
+import com.inks.hb.common.ExportExcel;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+@WebServlet(name = "AuthInfoExcelServlet", value = "/AuthInfoExcelServlet")
+public class AuthInfoExcelServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
+
+ AuthService service = new AuthServiceImpl();
+
+ ArrayList infoArrayList = null;
+ try {
+ infoArrayList = service.query(1, service.queryAuthInfoNum());
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ String[] headers = {"权限ID", "权限名称", "可读", "可写", "可改", "可删"};
+ String fileName = "权限信息";
+
+ ExportExcel ee = new ExportExcel<>();
+ ee.exportExcel(headers, infoArrayList, fileName, response);
+ }
+}
diff --git a/src/main/java/com/inks/hb/authinfo/controller/AuthInfoServlet.java b/src/main/java/com/inks/hb/authinfo/controller/AuthInfoServlet.java
new file mode 100644
index 0000000..15ccc67
--- /dev/null
+++ b/src/main/java/com/inks/hb/authinfo/controller/AuthInfoServlet.java
@@ -0,0 +1,102 @@
+package com.inks.hb.authinfo.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.authinfo.pojo.AuthInfo;
+import com.inks.hb.authinfo.service.AuthService;
+import com.inks.hb.authinfo.service.AuthServiceImpl;
+import com.inks.hb.common.PojotoGson;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+/**
+ * 分页查询权限表
+ * 如查询过程中出现异常,统一返回'数据查询出现异常'
+ * 返回数据为pojotoGson类型
+ */
+@WebServlet(value = "/AuthInfoServlet", name = "AuthInfoServlet")
+public class AuthInfoServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ PrintWriter out = response.getWriter();
+
+ int page = Integer.parseInt(request.getParameter("page")); // 当前页码
+ int limit = Integer.parseInt(request.getParameter("limit")); // 每页的数据量
+ int make = Integer.parseInt(request.getParameter("make"));
+
+ // 调用service
+ AuthService service = new AuthServiceImpl();
+
+ // 默认输出信息
+ String code = "0"; //状态码
+ String msg = "数据查询正常"; //状态信息
+ String count = ""; //数据总数
+ ArrayList list = new ArrayList<>(); //数据内容
+
+ //单个全局属性
+ int authId; //权限ID
+ String authItem = ""; //权限名称
+ String isRead; //可读
+ String isWrite; //可写
+ String isChange; //可改
+ String isDelete; //可删
+ AuthInfo authInfo = null;
+
+ try {
+
+ // 状态标志 make 0重载 1新增 2修改 3搜索 4删除
+ if (make == 2) {
+ authId = Integer.parseInt(request.getParameter("authId"));
+ authItem = request.getParameter("authItem");
+ isRead = request.getParameter("isRead");
+ isWrite = request.getParameter("isWrite");
+ isChange = request.getParameter("isChange");
+ isDelete = request.getParameter("isDelete");
+ authInfo = new AuthInfo(authId, authItem, isRead, isWrite, isChange, isDelete);
+ } else if (make == 3) {
+ authItem = request.getParameter("authItem");
+ }
+
+ switch (make) {
+ case 2:
+ service.updateAuthInfo(authInfo);
+ break;
+ case 3:
+ authInfo = service.query(authItem);
+ list.clear();
+ list.add(authInfo);
+ break;
+ }
+ if (make != 3) {
+ list = service.query(page, limit);
+ count = String.valueOf(service.queryAuthInfoNum());
+ } else {
+ if (authInfo.getAuthId() == 0) {
+ count = "0";
+ } else {
+ count = "1";
+ }
+ }
+ } catch (SQLException e) {
+ code = "1";
+ msg = "数据查询出现异常";
+ e.printStackTrace();
+ } finally {
+ PojotoGson pojotoGson = new PojotoGson(code, msg, count, list);
+ Gson gson = new Gson();
+ out.print(gson.toJson(pojotoGson));
+ }
+ }
+}
diff --git a/src/main/java/com/inks/hb/authinfo/dao/AuthInfoDao.java b/src/main/java/com/inks/hb/authinfo/dao/AuthInfoDao.java
new file mode 100644
index 0000000..476d902
--- /dev/null
+++ b/src/main/java/com/inks/hb/authinfo/dao/AuthInfoDao.java
@@ -0,0 +1,176 @@
+package com.inks.hb.authinfo.dao;
+
+import com.inks.hb.authinfo.pojo.AuthInfo;
+import com.inks.hb.common.CommonDao;
+import com.inks.hb.common.DBUtil;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+public class AuthInfoDao implements CommonDao {
+
+ @Override
+ public void insertData(Object o) throws SQLException {
+ AuthInfo authInfo = (AuthInfo) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "insert into authInfo (authItem, isRead, isWrite, isChange, isDelete) values (?,?,?,?,?)";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, authInfo.getAuthItem());
+ pstmt.setString(2, authInfo.getIsRead());
+ pstmt.setString(3, authInfo.getIsWrite());
+ pstmt.setString(4, authInfo.getIsChange());
+ pstmt.setString(5, authInfo.getIsDelete());
+
+ pstmt.executeUpdate();
+ pstmt.close();
+ }
+
+ @Override
+ public void deleteData(Object o) throws SQLException {
+ AuthInfo authInfo = (AuthInfo) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "DELETE FROM authInfo WHERE authId = ?";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setInt(1, authInfo.getAuthId());
+
+ pstmt.executeUpdate();
+ pstmt.close();
+ }
+
+ @Override
+ public void updateData(Object o) throws SQLException {
+ AuthInfo authInfo = (AuthInfo) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "UPDATE authInfo SET authItem = ? ,isRead = ?,isWrite = ?,isChange = ?,isDelete = ? WHERE authId = ?";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, authInfo.getAuthItem());
+ pstmt.setString(2, authInfo.getIsRead());
+ pstmt.setString(3, authInfo.getIsWrite());
+ pstmt.setString(4, authInfo.getIsChange());
+ pstmt.setString(5, authInfo.getIsDelete());
+ pstmt.setInt(6, authInfo.getAuthId());
+
+ pstmt.executeUpdate();
+ pstmt.close();
+ }
+
+ @Override
+ public int queryDataNum() throws SQLException {
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "select count(*) from authInfo;";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ ResultSet rs = pstmt.executeQuery();
+
+ int num;
+ if (rs.next()) num = rs.getInt("count(*)");
+ else num = 0;
+
+ rs.close();
+ pstmt.close();
+
+ return num;
+ }
+
+ @Override
+ public ArrayList query(int start, int length) throws SQLException {
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "select * from authInfo limit ?, ?;";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setInt(1, start - 1);
+ pstmt.setInt(2, length);
+ ResultSet rs = pstmt.executeQuery();
+
+ ArrayList list = new ArrayList<>();
+ AuthInfo authInfo;
+
+ while (rs.next()) {
+ authInfo = new AuthInfo(rs.getInt(1), rs.getString(2), rs.getString(3)
+ , rs.getString(4), rs.getString(5), rs.getString(6));
+ list.add(authInfo);
+ }
+
+ rs.close();
+ pstmt.close();
+
+ return list;
+ }
+
+ @Override
+ public Object query(Object o) throws SQLException {
+ AuthInfo authInfoQuery = (AuthInfo) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ //存在两种查:查ID和查NAME
+ String sql = "";
+ boolean isQueryId = false;
+ if (authInfoQuery.getAuthId() == 0)
+ sql = "SELECT * FROM authInfo WHERE authItem = ?";
+ else if (authInfoQuery.getAuthItem() == null) {
+ sql = "SELECT * FROM authInfo WHERE authId = ?";
+ isQueryId = true;
+ }
+
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ if (isQueryId) pstmt.setInt(1, authInfoQuery.getAuthId());
+ else pstmt.setString(1, authInfoQuery.getAuthItem());
+ ResultSet rs = pstmt.executeQuery();
+
+ AuthInfo authInfo = null;
+ while (rs.next()) {
+ authInfo = new AuthInfo(rs.getInt(1), rs.getString(2), rs.getString(3)
+ , rs.getString(4), rs.getString(5), rs.getString(6));
+ }
+
+ if (authInfo == null)
+ authInfo = new AuthInfo();
+
+ rs.close();
+ pstmt.close();
+
+ return authInfo;
+ }
+
+ /**
+ * 查询名称
+ *
+ * @param authInfoQuery 待查询对象
+ * @return 查询结果对象
+ * @throws SQLException 数据库
+ */
+ public AuthInfo queryName(AuthInfo authInfoQuery) throws SQLException {
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "SELECT * FROM authInfo WHERE authItem = ?";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, authInfoQuery.getAuthItem());
+ ResultSet rs = pstmt.executeQuery();
+
+ AuthInfo authInfo = null;
+ while (rs.next()) {
+ authInfo = new AuthInfo(rs.getInt(1), rs.getString(2), rs.getString(3)
+ , rs.getString(4), rs.getString(5), rs.getString(6));
+ }
+
+ if (authInfo == null)
+ authInfo = new AuthInfo();
+
+ rs.close();
+ pstmt.close();
+
+ return authInfo;
+ }
+}
diff --git a/src/main/java/com/inks/hb/authinfo/pojo/AuthInfo.java b/src/main/java/com/inks/hb/authinfo/pojo/AuthInfo.java
new file mode 100644
index 0000000..3094f0a
--- /dev/null
+++ b/src/main/java/com/inks/hb/authinfo/pojo/AuthInfo.java
@@ -0,0 +1,94 @@
+package com.inks.hb.authinfo.pojo;
+
+
+/**
+ * AuthInfo对象对应数据库中的authInfo表,主键为authID。
+ */
+public class AuthInfo {
+
+ private int authId; //权限ID
+
+ private String authItem; //权限名称
+
+ private String isRead; //可读
+
+ private String isWrite; //可写
+
+ private String isChange; //可改
+
+ private String isDelete; //可删
+
+ public AuthInfo() {
+ super();
+ }
+
+ public AuthInfo(int authId, String authItem, String isRead, String isWrite, String isChange, String isDelete) {
+ this.authId = authId;
+ this.authItem = authItem;
+ this.isRead = isRead;
+ this.isWrite = isWrite;
+ this.isChange = isChange;
+ this.isDelete = isDelete;
+ }
+
+ public int getAuthId() {
+ return authId;
+ }
+
+ public void setAuthId(int authId) {
+ this.authId = authId;
+ }
+
+ public String getAuthItem() {
+ return authItem;
+ }
+
+ public void setAuthItem(String authItem) {
+ this.authItem = authItem;
+ }
+
+ public String getIsRead() {
+ return isRead;
+ }
+
+ public void setIsRead(String isRead) {
+ this.isRead = isRead;
+ }
+
+ public String getIsWrite() {
+ return isWrite;
+ }
+
+ public void setIsWrite(String isWrite) {
+ this.isWrite = isWrite;
+ }
+
+ public String getIsChange() {
+ return isChange;
+ }
+
+ public void setIsChange(String isChange) {
+ this.isChange = isChange;
+ }
+
+ public String getIsDelete() {
+ return isDelete;
+ }
+
+ public void setIsDelete(String idDelete) {
+ this.isDelete = idDelete;
+ }
+
+ @Override
+ public String toString() {
+ return "\n--->AuthInfo对象信息输出:" +
+ "\n authId = " + authId +
+ "\n authItem = '" + authItem + '\'' +
+ "\n isRead = '" + isRead + '\'' +
+ "\n isWrite = '" + isWrite + '\'' +
+ "\n isChange = " + isChange +
+ "\n idDelete = " + isDelete +
+ "\n--->AuthInfo信息输出结束\n";
+
+ }
+}
diff --git a/src/main/java/com/inks/hb/authinfo/service/AuthService.java b/src/main/java/com/inks/hb/authinfo/service/AuthService.java
new file mode 100644
index 0000000..c9a52bb
--- /dev/null
+++ b/src/main/java/com/inks/hb/authinfo/service/AuthService.java
@@ -0,0 +1,59 @@
+package com.inks.hb.authinfo.service;
+
+import com.inks.hb.authinfo.pojo.AuthInfo;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+/**
+ * AuthService
+ */
+public interface AuthService {
+
+
+ /**
+ * 查询AuthInfo表的长度
+ *
+ * @return 权限表长度
+ * @throws SQLException 数据库
+ */
+ int queryAuthInfoNum() throws SQLException;
+
+ /**
+ * 根据权限ID查询权限表
+ *
+ * @param authId ID
+ * @return 权限表,如果无结果,返回空参构造对象
+ * @throws SQLException 数据库
+ */
+ AuthInfo query(int authId) throws SQLException;
+
+ /**
+ * 根据权限名称查询权限表
+ *
+ * @param authItem 权限项目
+ * @return 权限表,如果无结果,返回空参构造对象
+ * @throws SQLException 数据库
+ */
+ AuthInfo query(String authItem) throws SQLException;
+
+ /**
+ * 分页查询权限表中数据
+ * page和limit参数是有layui框架的table传递过来的
+ *
+ * @param page 当前页码
+ * @param limit 每页的数据量
+ * @return 返回请求页数的数据
+ * @throws SQLException 数据库
+ */
+ ArrayList query(int page, int limit) throws SQLException;
+
+ /**
+ * 根据ID修改权限表属性
+ *
+ * @param authInfo 完整权限对象
+ * @throws SQLException 数据库
+ */
+ void updateAuthInfo(AuthInfo authInfo) throws SQLException;
+
+}
diff --git a/src/main/java/com/inks/hb/authinfo/service/AuthServiceImpl.java b/src/main/java/com/inks/hb/authinfo/service/AuthServiceImpl.java
new file mode 100644
index 0000000..658911e
--- /dev/null
+++ b/src/main/java/com/inks/hb/authinfo/service/AuthServiceImpl.java
@@ -0,0 +1,51 @@
+package com.inks.hb.authinfo.service;
+
+import com.inks.hb.authinfo.dao.AuthInfoDao;
+import com.inks.hb.authinfo.pojo.AuthInfo;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+public class AuthServiceImpl implements AuthService {
+
+ private AuthInfoDao dao = new AuthInfoDao();
+
+ @Override
+ public int queryAuthInfoNum() throws SQLException {
+
+ return dao.queryDataNum();
+ }
+
+ @Override
+ public AuthInfo query(int authId) throws SQLException {
+ AuthInfo authInfo = new AuthInfo();
+ authInfo.setAuthId(authId);
+
+ return (AuthInfo) dao.query(authInfo);
+ }
+
+ @Override
+ public AuthInfo query(String authItem) throws SQLException {
+ AuthInfo authInfo = new AuthInfo();
+ authInfo.setAuthItem(authItem);
+
+ return dao.queryName(authInfo);
+ }
+
+ @Override
+ public ArrayList query(int page, int limit) throws SQLException {
+
+ int start = (page * limit) - limit + 1; //每一页的起始位置
+
+ if (start < 1)
+ start = 1;
+
+ return dao.query(start, limit);
+ }
+
+ @Override
+ public void updateAuthInfo(AuthInfo authInfo) throws SQLException {
+
+ dao.updateData(authInfo);
+ }
+}
diff --git a/src/main/java/com/inks/hb/billinfo/pojo/BillInfo.java b/src/main/java/com/inks/hb/billinfo/pojo/BillInfo.java
new file mode 100644
index 0000000..bbab7db
--- /dev/null
+++ b/src/main/java/com/inks/hb/billinfo/pojo/BillInfo.java
@@ -0,0 +1,80 @@
+package com.inks.hb.billinfo.pojo;
+
+/**
+ * 账单表
+ */
+public class BillInfo {
+
+ private int billId;
+
+ private String checkedId;
+
+ private String costMoney;
+
+ private String costDate;
+
+ private String remark;
+
+ public BillInfo() {
+ super();
+ }
+
+ public BillInfo(int billId, String checkedId, String costMoney, String costDate, String remark) {
+ this.billId = billId;
+ this.checkedId = checkedId;
+ this.costMoney = costMoney;
+ this.costDate = costDate;
+ this.remark = remark;
+ }
+
+ public int getBillId() {
+ return billId;
+ }
+
+ public void setBillId(int billId) {
+ this.billId = billId;
+ }
+
+ public String getCheckedId() {
+ return checkedId;
+ }
+
+ public void setCheckedId(String checkedId) {
+ this.checkedId = checkedId;
+ }
+
+ public String getCostMoney() {
+ return costMoney;
+ }
+
+ public void setCostMoney(String costMoney) {
+ this.costMoney = costMoney;
+ }
+
+ public String getCostDate() {
+ return costDate;
+ }
+
+ public void setCostDate(String costDate) {
+ this.costDate = costDate;
+ }
+
+ public String getRemark() {
+ return remark;
+ }
+
+ public void setRemark(String remark) {
+ this.remark = remark;
+ }
+
+ @Override
+ public String toString() {
+ return "BillInfo{" +
+ "billId=" + billId +
+ ", checkedId='" + checkedId + '\'' +
+ ", costMoney='" + costMoney + '\'' +
+ ", costDate='" + costDate + '\'' +
+ ", remark='" + remark + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/com/inks/hb/common/CommonDao.java b/src/main/java/com/inks/hb/common/CommonDao.java
new file mode 100644
index 0000000..1d55554
--- /dev/null
+++ b/src/main/java/com/inks/hb/common/CommonDao.java
@@ -0,0 +1,29 @@
+package com.inks.hb.common;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+/**
+ * 本文件是一个公共的DAO接口,相同Dao的调用关系集合。
+ * 在此之前已经完成Login、floorInfo、authInfo,如果有时间,就改造他们的函数。
+ * 1.增 添加单条数据
+ * 2.删 根据XXX删单条数据
+ * 3.改 根据XXX改单条数据
+ * 4.查 查表长度
+ * 5.查 根据XXX查单条数据 ---> 在service层抽出查重函数
+ * 6.查 查所有数据 ---> 根据数据起始位置和长度返回ArrayList
+ */
+public interface CommonDao {
+
+ void insertData(Object o) throws SQLException;
+
+ void deleteData(Object o) throws SQLException;
+
+ void updateData(Object o) throws SQLException;
+
+ int queryDataNum() throws SQLException;
+
+ ArrayList query(int start, int length) throws SQLException;
+
+ Object query(Object o) throws SQLException;
+}
diff --git a/src/main/java/com/inks/hb/common/CommonFilter.java b/src/main/java/com/inks/hb/common/CommonFilter.java
new file mode 100644
index 0000000..89d7c5d
--- /dev/null
+++ b/src/main/java/com/inks/hb/common/CommonFilter.java
@@ -0,0 +1,67 @@
+package com.inks.hb.common;
+
+import javax.servlet.*;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+
+/**
+ * 过滤器,拦截所有请求。
+ * 仅当session中包含登录成功后的登录名后才放行请求
+ */
+@WebFilter(value = "/*", filterName = "CommonFilter") //拦截所有请求
+public class CommonFilter implements Filter {
+ public void destroy() {
+ }
+
+ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
+
+ // 转换为子接口类型
+ HttpServletRequest request = (HttpServletRequest) req;
+ HttpServletResponse response = (HttpServletResponse) resp;
+
+ //设置响应报头允许当前应用被跨域请求(CROS)
+ response.setHeader("Access-Control-Allow-Origin", "*");
+
+ HttpSession session = request.getSession();
+
+ // 获得用户请求的URL
+ String url = request.getRequestURI();
+ boolean check = false;
+
+ // 因为是全局过滤,所以会对所有请求进行过滤,诸如css、js、png等等
+ // 所以应该做到只拦截.html和.jsp请求,对请求地址的末尾进行判断
+ // 修订 servlet加入拦截过滤范围
+ if (url.endsWith(".jsp") || url.endsWith(".html") || url.endsWith("Servlet"))
+ check = true;
+
+ // 判断登录请求的servlet不过滤
+ if (url.endsWith("/hb/QueryLoginNameServlet"))
+ check = false;
+
+ if (!url.equals("/hb") && check) {
+ // 判断session中此值是否存在
+ if (session.getAttribute("LoginName") != null) {
+ //System.out.println("---->通过】");
+ chain.doFilter(request, response); //放行
+ } else {
+ //System.out.println("---->未通过!】");
+ response.sendRedirect("/hb"); //跳转回根目录
+ }
+ } else {
+ // 非html和jsp请求一律不管
+ chain.doFilter(request, response);
+ }
+
+
+ // 请求响应结束之后调用统一关闭连接方法
+ DBUtil.close();
+ }
+
+ public void init(FilterConfig config) {
+
+ }
+
+}
diff --git a/src/main/java/com/inks/hb/common/DBUtil.java b/src/main/java/com/inks/hb/common/DBUtil.java
new file mode 100644
index 0000000..5ff08b8
--- /dev/null
+++ b/src/main/java/com/inks/hb/common/DBUtil.java
@@ -0,0 +1,63 @@
+package com.inks.hb.common;
+
+
+import com.mchange.v2.c3p0.ComboPooledDataSource;
+
+import java.sql.Connection;
+
+import java.sql.SQLException;
+
+/**
+ * 数据库工具类 - 使用连接池进行连接
+ */
+public class DBUtil {
+
+ private static ComboPooledDataSource dataSource;
+
+ private static ThreadLocal threadLocal = new ThreadLocal<>();// 本地线程对象
+
+ static {
+ try {
+ // 读取配置文件的mysql字段信息
+ dataSource = new ComboPooledDataSource("mysql");
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ }
+ }
+
+ /**
+ * 通过连接池对象返回数据库连接
+ *
+ * @return Connection 连接对象
+ * @throws SQLException 数据库错误
+ */
+ public static Connection getConnection() throws SQLException {
+ // 从threadLocal获得连接对象
+ Connection conn = threadLocal.get();
+
+ // 如果连接对象不存在或者是已经被关闭的,就从连接池取出一个连接对象返回,如果已经存在,就直接返回
+ if (conn == null || conn.isClosed()) {
+ conn = dataSource.getConnection();
+ // 设置到threadLocal中
+ threadLocal.set(conn);
+ }
+ return conn;
+ }
+
+
+ public static void close() {
+ // 从本地线程中获得连接
+ Connection conn = threadLocal.get();
+ try {
+ // 在连接不为空 且 没关闭时
+ if (conn != null && !conn.isClosed()) {
+ // 解除绑定
+ threadLocal.set(null);
+ // 关闭连接
+ conn.close();
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/inks/hb/common/ExitSystemServlet.java b/src/main/java/com/inks/hb/common/ExitSystemServlet.java
new file mode 100644
index 0000000..3c3fe8d
--- /dev/null
+++ b/src/main/java/com/inks/hb/common/ExitSystemServlet.java
@@ -0,0 +1,45 @@
+package com.inks.hb.common;
+
+import com.inks.hb.logInfo.pojo.LogInfo;
+import com.inks.hb.logInfo.service.LogInfoService;
+import com.inks.hb.logInfo.service.LogInfoServiceImpl;
+import com.inks.hb.login.pojo.Login;
+import com.inks.hb.login.service.LoginService;
+import com.inks.hb.login.service.LoginServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.*;
+import java.sql.SQLException;
+
+/**
+ * 作用 退出系统时 清除session
+ */
+@WebServlet(value = "/ExitSystemServlet", name = "ExitSystemServlet")
+public class ExitSystemServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
+
+ HttpSession session = request.getSession();
+
+ if (session.getAttribute("LoginName") != null) {
+ //System.out.println("已清除---> LoginName的session值\n");
+ String loginName = request.getSession().getAttribute("LoginName").toString();
+ session.removeAttribute("LoginName");
+ //写入退出记录
+ LoginService service = new LoginServiceImpl();
+ Login login = null;
+ try {
+ login = service.queryLogin(loginName);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ LogInfo logInfo = new LogInfo("退出", login.getLoginId(), loginName);
+ LogInfoService logInfoService = new LogInfoServiceImpl();
+ logInfoService.insertLogInfo(logInfo);
+
+ }
+ }
+}
diff --git a/src/main/java/com/inks/hb/common/ExportExcel.java b/src/main/java/com/inks/hb/common/ExportExcel.java
new file mode 100644
index 0000000..c547902
--- /dev/null
+++ b/src/main/java/com/inks/hb/common/ExportExcel.java
@@ -0,0 +1,109 @@
+package com.inks.hb.common;
+
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
+import org.apache.poi.xssf.usermodel.XSSFRow;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+public class ExportExcel {
+ public void exportExcel(String[] headers, Collection dataset, String fileName, HttpServletResponse response) {
+ // 声明一个工作薄
+ XSSFWorkbook workbook = new XSSFWorkbook();
+ // 生成一个表格
+ XSSFSheet sheet = workbook.createSheet(fileName);
+ // 设置表格默认列宽度为15个字节
+ sheet.setDefaultColumnWidth((short) 20);
+ // 产生表格标题行
+ XSSFRow row = sheet.createRow(0);
+ for (short i = 0; i < headers.length; i++) {
+ XSSFCell cell = row.createCell(i);
+ XSSFRichTextString text = new XSSFRichTextString(headers[i]);
+ cell.setCellValue(text);
+ }
+
+ try {
+ // 遍历集合数据,产生数据行
+ Iterator it = dataset.iterator();
+ int index = 0;
+ while (it.hasNext()) {
+ index++;
+ row = sheet.createRow(index);
+ T t = (T) it.next();
+ // 利用反射,根据javabean属性的先后顺序,动态调用getXxx()方法得到属性值
+ Field[] fields = t.getClass().getDeclaredFields();
+ for (short i = 0; i < headers.length; i++) {
+ XSSFCell cell = row.createCell(i);
+ Field field = fields[i];
+ String fieldName = field.getName();
+ String getMethodName = "get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
+ Class tCls = t.getClass();
+ Method getMethod = tCls.getMethod(getMethodName, new Class[]{});
+ Object value = getMethod.invoke(t, new Object[]{});
+ // 判断值的类型后进行强制类型转换
+ String textValue = null;
+ // 其它数据类型都当作字符串简单处理
+ if (value != null && value != "") {
+ textValue = value.toString();
+ }
+ if (textValue != null) {
+ XSSFRichTextString richString = new XSSFRichTextString(textValue);
+ cell.setCellValue(richString);
+ }
+ }
+ }
+ getExportedFile(workbook, fileName, response);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 方法说明: 指定路径下生成EXCEL文件
+ */
+ public void getExportedFile(XSSFWorkbook workbook, String name, HttpServletResponse response) throws Exception {
+ BufferedOutputStream fos = null;
+ try {
+ String fileName = name + ".xlsx";
+ response.setContentType("application/x-msdownload");
+ response.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes("utf-8"), "ISO8859-1"));
+ fos = new BufferedOutputStream(response.getOutputStream());
+ workbook.write(fos);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (fos != null) {
+ fos.close();
+ }
+ }
+ }
+
+ public static ArrayList readXlsx(String path) throws IOException {
+ XSSFWorkbook xwb = new XSSFWorkbook(path);
+ XSSFSheet sheet = xwb.getSheetAt(0);
+ XSSFRow row;
+ String[] cell = new String[sheet.getPhysicalNumberOfRows() + 1];
+ ArrayList arrayList = new ArrayList<>();
+ for (int i = sheet.getFirstRowNum() + 1; i < sheet.getPhysicalNumberOfRows(); i++) {
+ cell[i] = "";
+ row = sheet.getRow(i);
+ for (int j = row.getFirstCellNum(); j < row.getPhysicalNumberOfCells(); j++) {
+ cell[i] += row.getCell(j).toString();
+ cell[i] += " | ";
+ }
+ arrayList.add(cell[i]);
+ }
+ return arrayList;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/inks/hb/common/MD5.java b/src/main/java/com/inks/hb/common/MD5.java
new file mode 100644
index 0000000..f4279b6
--- /dev/null
+++ b/src/main/java/com/inks/hb/common/MD5.java
@@ -0,0 +1,22 @@
+package com.inks.hb.common;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+public class MD5 {
+
+ public String getMD5(String str) {
+ String Salt = "mH8yhBL-n*j-2gmC" + str;
+ return Base64.getEncoder().encodeToString(Salt.getBytes(StandardCharsets.UTF_8));
+ }
+
+ public boolean checkMD5(String newStr, String oldStr) {
+ return getMD5(newStr).equals(oldStr);
+ }
+
+ public static void main(String[] args) {
+ MD5 md5 = new MD5();
+ System.out.println(md5.getMD5("toor"));
+ }
+}
+
diff --git a/src/main/java/com/inks/hb/common/PojotoGson.java b/src/main/java/com/inks/hb/common/PojotoGson.java
new file mode 100644
index 0000000..8e541e5
--- /dev/null
+++ b/src/main/java/com/inks/hb/common/PojotoGson.java
@@ -0,0 +1,35 @@
+package com.inks.hb.common;
+
+import java.util.List;
+
+/**
+ * 抽象出一个统一的toJson类
+ * 最主要用途是包装ArrayList的各个pojo对象
+ */
+public class PojotoGson {
+
+ private String code; //数据状态字段
+
+ private String msg; //状态字段名
+
+ private String count; //数据总数
+
+ private List data; //数据
+
+ public PojotoGson(String code, String msg, String count, List data) {
+ this.code = code;
+ this.msg = msg;
+ this.count = count;
+ this.data = data;
+ }
+
+ @Override
+ public String toString() {
+ return "PojotoGson{" +
+ "code='" + code + '\'' +
+ ", msg='" + msg + '\'' +
+ ", count='" + count + '\'' +
+ ", data=" + data +
+ '}';
+ }
+}
diff --git a/src/main/java/com/inks/hb/floorinfo/controller/FloorInfoExcelServlet.java b/src/main/java/com/inks/hb/floorinfo/controller/FloorInfoExcelServlet.java
new file mode 100644
index 0000000..c7c65a5
--- /dev/null
+++ b/src/main/java/com/inks/hb/floorinfo/controller/FloorInfoExcelServlet.java
@@ -0,0 +1,33 @@
+package com.inks.hb.floorinfo.controller;
+
+import com.inks.hb.common.ExportExcel;
+import com.inks.hb.floorinfo.pojo.FloorInfo;
+import com.inks.hb.floorinfo.service.FloorInfoService;
+import com.inks.hb.floorinfo.service.FloorInfoServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+
+@WebServlet(name = "FloorInfoExcelServlet", value = "/FloorInfoExcelServlet")
+public class FloorInfoExcelServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
+
+ FloorInfoService service = new FloorInfoServiceImpl();
+
+ ArrayList infoArrayList = null;
+ infoArrayList = service.query(1, service.queryFloorInfoNum());
+
+ String[] headers = {"楼层编号", "楼层名称"};
+ String fileName = "楼层信息";
+
+ ExportExcel ee = new ExportExcel<>();
+ ee.exportExcel(headers, infoArrayList, fileName, response);
+ }
+}
diff --git a/src/main/java/com/inks/hb/floorinfo/controller/FloorInfoServlet.java b/src/main/java/com/inks/hb/floorinfo/controller/FloorInfoServlet.java
new file mode 100644
index 0000000..6addf2c
--- /dev/null
+++ b/src/main/java/com/inks/hb/floorinfo/controller/FloorInfoServlet.java
@@ -0,0 +1,119 @@
+package com.inks.hb.floorinfo.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.common.PojotoGson;
+import com.inks.hb.floorinfo.pojo.FloorInfo;
+import com.inks.hb.floorinfo.service.FloorInfoService;
+import com.inks.hb.floorinfo.service.FloorInfoServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+
+/**
+ * 与表格相关的全部操作
+ * 状态标志: make 0重载 1新增 2修改 3搜索 4删除
+ */
+@WebServlet(name = "FloorInfoServlet", value = "/FloorInfoServlet")
+public class FloorInfoServlet extends HttpServlet {
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ this.doGet(request, response);
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ PrintWriter out = response.getWriter();
+
+ Gson gson = new Gson();
+ out.print(gson.toJson(doMyServlet(request)));
+ }
+
+ private PojotoGson doMyServlet(HttpServletRequest request) {
+
+ int page = Integer.parseInt(request.getParameter("page")); //当前页码
+ int limit = Integer.parseInt(request.getParameter("limit")); //每页的数据量
+ int make = Integer.parseInt(request.getParameter("make")); //状态标志
+
+ // 调用service
+ FloorInfoService service = new FloorInfoServiceImpl();
+
+ // 默认输出信息
+ String code = "0"; //状态码
+ String msg = "数据查询正常"; //状态信息
+ String count = ""; //数据总数
+ ArrayList list = new ArrayList<>(); //数据内容
+ ArrayList searchList = new ArrayList<>(); //数据内容
+
+ //单个全局属性
+ int floorId = 0;
+ String floorName = "";
+ FloorInfo floorInfo = new FloorInfo();
+
+ //获取对应状态属性
+ if (make == 1 || make == 3) {
+ floorName = request.getParameter("floorName");
+ } else if (make == 2) {
+ floorId = Integer.parseInt(request.getParameter("floorId"));
+ floorName = request.getParameter("floorName");
+ floorInfo = new FloorInfo(floorId, floorName);
+ } else if (make == 4) {
+ floorId = Integer.parseInt(request.getParameter("floorId"));
+ }
+
+ // 状态标志 make 0重载 1新增 2修改 3搜索 4删除
+ switch (make) {
+ case 1:
+ if (service.insertFloorInfo(floorName) == -1) {
+ msg = "插入异常";
+ code = "-1";
+ }
+ break;
+ case 2:
+ if (service.updateFloorInfo(floorInfo) == -1) {
+ msg = "修改异常";
+ code = "-1";
+ }
+ break;
+ case 3:
+ list = service.query(1, service.queryFloorInfoNum());
+ searchList.clear();
+ for (Object temp : list) {
+ floorInfo = (FloorInfo) temp; //用contains模糊查询 机智啊,这样连mysql的like语句都不用写 --2017.12.7 改
+ if (floorInfo.getFloorName().contains(floorName)) {
+ searchList.add(floorInfo);
+ }
+ }
+ break;
+ case 4:
+ if (service.deleteFloorInfo(floorId) == -1) {
+ msg = "删除失败";
+ code = "-1";
+ }
+ break;
+ }
+
+ if (make != 3) {
+ list = service.query(page, limit);
+ count = String.valueOf(service.queryFloorInfoNum());
+ } else { //这部分算是对3搜索的特殊处理,放这儿和放case里一样的。
+ int size = searchList.size();
+ if (size == 0) {
+ msg = "查无此项";
+ code = "-1";
+ } else {
+ list = searchList;
+ count = Integer.toString(size);
+ }
+ }
+ return new PojotoGson(code, msg, count, list);
+ }
+}
diff --git a/src/main/java/com/inks/hb/floorinfo/controller/QueryFloorNameServlet.java b/src/main/java/com/inks/hb/floorinfo/controller/QueryFloorNameServlet.java
new file mode 100644
index 0000000..cfe54c3
--- /dev/null
+++ b/src/main/java/com/inks/hb/floorinfo/controller/QueryFloorNameServlet.java
@@ -0,0 +1,38 @@
+package com.inks.hb.floorinfo.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.floorinfo.service.FloorInfoService;
+import com.inks.hb.floorinfo.service.FloorInfoServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * 新增操作时判断数据库中已经拥有此角色
+ */
+@WebServlet(name = "QueryFloorNameServlet", value = "/QueryFloorNameServlet")
+public class QueryFloorNameServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ PrintWriter out = response.getWriter();
+
+ // 调用service
+ FloorInfoService service = new FloorInfoServiceImpl();
+
+ String newName = request.getParameter("new"); //获得姓名
+ String oldName = request.getParameter("old");
+ // 转换为json字符串格式
+ Gson gson = new Gson();
+ out.print(gson.toJson(service.queryRepeat(newName, oldName)));
+ }
+}
diff --git a/src/main/java/com/inks/hb/floorinfo/dao/FloorInfoDao.java b/src/main/java/com/inks/hb/floorinfo/dao/FloorInfoDao.java
new file mode 100644
index 0000000..77b02f5
--- /dev/null
+++ b/src/main/java/com/inks/hb/floorinfo/dao/FloorInfoDao.java
@@ -0,0 +1,130 @@
+package com.inks.hb.floorinfo.dao;
+
+import com.inks.hb.common.CommonDao;
+import com.inks.hb.common.DBUtil;
+import com.inks.hb.floorinfo.pojo.FloorInfo;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+/**
+ * 楼层 DAO
+ * 未提供独立函数
+ */
+public class FloorInfoDao implements CommonDao {
+ @Override
+ public void insertData(Object o) throws SQLException {
+ FloorInfo floorInfo = (FloorInfo) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "INSERT INTO floorInfo (floorName) VALUES (?)";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, floorInfo.getFloorName());
+ pstmt.executeUpdate();
+
+ pstmt.close();
+ }
+
+ @Override
+ public void deleteData(Object o) throws SQLException {
+ FloorInfo floorInfo = (FloorInfo) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "DELETE FROM floorInfo WHERE floorId = ?";
+ PreparedStatement ps = conn.prepareStatement(sql);
+ ps.setInt(1, floorInfo.getFloorId());
+ ps.executeUpdate();
+
+ ps.close();
+ }
+
+ @Override
+ public void updateData(Object o) throws SQLException {
+ FloorInfo floorInfo = (FloorInfo) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "UPDATE floorInfo SET floorName = ? WHERE floorId = ?";
+ PreparedStatement ps = conn.prepareStatement(sql);
+ ps.setString(1, floorInfo.getFloorName());
+ ps.setInt(2, floorInfo.getFloorId());
+ ps.executeUpdate();
+
+ ps.close();
+ }
+
+ @Override
+ public int queryDataNum() throws SQLException {
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "select count(*) from floorInfo;";
+ PreparedStatement ps = conn.prepareStatement(sql);
+ ResultSet rs = ps.executeQuery();
+
+ int num = 0;
+ if (rs.next())
+ num = rs.getInt("count(*)");
+
+ rs.close();
+ ps.close();
+
+ return num;
+ }
+
+ @Override
+ public ArrayList query(int start, int length) throws SQLException {
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "select * from floorInfo limit ?, ?;";
+ PreparedStatement ps = conn.prepareStatement(sql);
+ ps.setInt(1, start - 1);
+ ps.setInt(2, length);
+ ResultSet rs = ps.executeQuery();
+
+ ArrayList list = new ArrayList<>();
+ FloorInfo authInfo;
+ while (rs.next()) {
+ authInfo = new FloorInfo(rs.getInt(1), rs.getString(2));
+ list.add(authInfo);
+ }
+
+ rs.close();
+ ps.close();
+
+ return list;
+ }
+
+ @Override
+ public Object query(Object o) throws SQLException {
+ FloorInfo floorInfoQuery = (FloorInfo) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "SELECT * FROM floorInfo WHERE floorName = ?";
+ PreparedStatement pstms = conn.prepareStatement(sql);
+ pstms.setString(1, floorInfoQuery.getFloorName());
+ ResultSet rs = pstms.executeQuery();
+
+ FloorInfo floorInfo = null;
+ if (rs.next())
+ floorInfo = new FloorInfo(rs.getInt(1), rs.getString(2));
+
+ if (floorInfo == null) {
+ floorInfo = new FloorInfo();
+ floorInfo.setNull(true);
+ }
+
+ rs.close();
+ pstms.close();
+
+ return floorInfo;
+ }
+
+}
diff --git a/src/main/java/com/inks/hb/floorinfo/pojo/FloorInfo.java b/src/main/java/com/inks/hb/floorinfo/pojo/FloorInfo.java
new file mode 100644
index 0000000..bea820a
--- /dev/null
+++ b/src/main/java/com/inks/hb/floorinfo/pojo/FloorInfo.java
@@ -0,0 +1,64 @@
+package com.inks.hb.floorinfo.pojo;
+
+/**
+ * 楼层信息
+ * 2017.11.23 --------
+ * 添加isNull字段,现在可以通过setNull设置元素信息,通过isNull读取信息
+ * 原构造函数不变,不提供含该字段的构造函数,该字段应主要用于查询函数(查询函数不返回未实例化的对象)
+ * ------------
+ */
+public class FloorInfo {
+
+ private int floorId; //楼层编号
+
+ private String floorName; //楼层名称
+
+ private boolean isNull; //是否为空值对象
+
+ public FloorInfo() {
+ super();
+ }
+
+ public FloorInfo(int floorId, String floorName) {
+ this.floorId = floorId;
+ this.floorName = floorName;
+ }
+
+ public int getFloorId() {
+ return floorId;
+ }
+
+ public void setFloorId(int floorId) {
+ this.floorId = floorId;
+ }
+
+ public String getFloorName() {
+ return floorName;
+ }
+
+ public void setFloorName(String floorName) {
+ this.floorName = floorName;
+ }
+
+ public boolean isNull() {
+ return isNull;
+ }
+
+ /**
+ * 如果为null,则设置为true,否则false
+ *
+ * @param aNull 对象是否为空
+ */
+ public void setNull(boolean aNull) {
+ isNull = aNull;
+ }
+
+ @Override
+ public String toString() {
+ return "FloorInfo{" +
+ "floorId=" + floorId +
+ ", floorName='" + floorName + '\'' +
+ ", isNull=" + isNull +
+ '}';
+ }
+}
diff --git a/src/main/java/com/inks/hb/floorinfo/service/FloorInfoService.java b/src/main/java/com/inks/hb/floorinfo/service/FloorInfoService.java
new file mode 100644
index 0000000..da33fb9
--- /dev/null
+++ b/src/main/java/com/inks/hb/floorinfo/service/FloorInfoService.java
@@ -0,0 +1,38 @@
+package com.inks.hb.floorinfo.service;
+
+import com.inks.hb.floorinfo.pojo.FloorInfo;
+
+import java.util.ArrayList;
+
+/**
+ * 数据异常在本层解决
+ * 但凡出现SQL方面异常均返回-1
+ */
+public interface FloorInfoService {
+
+ //增添
+ int insertFloorInfo(String floorName);
+
+ //删除
+ int deleteFloorInfo(int floorId);
+
+ //更新
+ int updateFloorInfo(FloorInfo floorInfo);
+
+ //查询多条
+ ArrayList query(int page, int limit);
+
+ //查询单条
+ FloorInfo query(String floorName);
+
+ //查询长度
+ int queryFloorInfoNum();
+
+ /**
+ * 独立的查重函数
+ *
+ * @param newName oldName 楼层名称
+ * @return 0:已经存在 1:未存在 2:与自身相同
+ */
+ int queryRepeat(String newName, String oldName);
+}
diff --git a/src/main/java/com/inks/hb/floorinfo/service/FloorInfoServiceImpl.java b/src/main/java/com/inks/hb/floorinfo/service/FloorInfoServiceImpl.java
new file mode 100644
index 0000000..aa8c63c
--- /dev/null
+++ b/src/main/java/com/inks/hb/floorinfo/service/FloorInfoServiceImpl.java
@@ -0,0 +1,120 @@
+package com.inks.hb.floorinfo.service;
+
+import com.inks.hb.floorinfo.dao.FloorInfoDao;
+import com.inks.hb.floorinfo.pojo.FloorInfo;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+/**
+ * 修订:2017.11.23
+ * 将异常放在了本层处理
+ * 如果出现数据库相关异常,则返回-1或者null
+ */
+public class FloorInfoServiceImpl implements FloorInfoService {
+
+ private FloorInfoDao dao = new FloorInfoDao();
+
+ @Override
+ public int insertFloorInfo(String floorName) {
+ FloorInfo floorInfoQuery = new FloorInfo();
+ floorInfoQuery.setFloorName(floorName);
+
+ FloorInfo floorInfo;
+ try {
+ floorInfo = (FloorInfo) dao.query(floorInfoQuery);
+ if (floorInfo.isNull())
+ dao.insertData(floorInfoQuery);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return -1;
+ }
+ return 1;
+ }
+
+ @Override
+ public int deleteFloorInfo(int floorId) {
+ FloorInfo floorInfoQuery = new FloorInfo();
+ floorInfoQuery.setFloorId(floorId);
+
+ try {
+ dao.deleteData(floorInfoQuery);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return -1;
+ }
+ return 1;
+ }
+
+ @Override
+ public int updateFloorInfo(FloorInfo floorInfo) {
+
+ try {
+ dao.updateData(floorInfo);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return -1;
+ }
+ return 1;
+ }
+
+ @Override
+ public ArrayList query(int page, int limit) {
+
+ int start = (page * limit) - limit + 1; //每一页的起始位置
+
+ if (start < 1) //小于1的话会触发一个错误
+ start = 1; //但是理论上page和limit是由table表格生成的参数
+
+ try {
+ return dao.query(start, limit);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return null;
+ }
+ }
+
+ @Override
+ public FloorInfo query(String floorName) {
+ FloorInfo floorInfoQuery = new FloorInfo();
+ floorInfoQuery.setFloorName(floorName);
+
+ try {
+ return (FloorInfo) dao.query(floorInfoQuery);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return null;
+ }
+ }
+
+ @Override
+ public int queryFloorInfoNum() {
+
+ try {
+ return dao.queryDataNum();
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return -1;
+ }
+ }
+
+ @Override
+ public int queryRepeat(String newName, String oldName) {
+ FloorInfo floorInfoQuery = new FloorInfo();
+ floorInfoQuery.setFloorName(newName);
+ FloorInfo floorInfo;
+ try {
+ floorInfo = (FloorInfo) dao.query(floorInfoQuery);
+ if (!floorInfo.isNull()) { //表示存在同名项
+ if (floorInfo.getFloorName().equals(oldName))
+ return 2; //表示存在同名项,但是是与传递来的相同
+ return 0;
+ } else
+ return 1;
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return -1;
+ }
+ }
+
+}
diff --git a/src/main/java/com/inks/hb/logInfo/controller/LogInfoExcelServlet.java b/src/main/java/com/inks/hb/logInfo/controller/LogInfoExcelServlet.java
new file mode 100644
index 0000000..7d0bf18
--- /dev/null
+++ b/src/main/java/com/inks/hb/logInfo/controller/LogInfoExcelServlet.java
@@ -0,0 +1,32 @@
+package com.inks.hb.logInfo.controller;
+
+import com.inks.hb.common.ExportExcel;
+import com.inks.hb.logInfo.pojo.LogInfo;
+import com.inks.hb.logInfo.service.LogInfoService;
+import com.inks.hb.logInfo.service.LogInfoServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+
+@WebServlet(name = "LogInfoExcelServlet", value = "/LogInfoExcelServlet")
+public class LogInfoExcelServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
+ LogInfoService service = new LogInfoServiceImpl();
+
+ ArrayList infoArrayList;
+ infoArrayList = service.query(1, service.queryLogInfoNum());
+
+ String[] headers = {"日志编号", "内容", "用户编号", "用户名称", "日期"};
+ String fileName = "日志信息";
+
+ ExportExcel ee = new ExportExcel<>();
+ ee.exportExcel(headers, infoArrayList, fileName, response);
+ }
+}
diff --git a/src/main/java/com/inks/hb/logInfo/controller/LogInfoServlet.java b/src/main/java/com/inks/hb/logInfo/controller/LogInfoServlet.java
new file mode 100644
index 0000000..9eee280
--- /dev/null
+++ b/src/main/java/com/inks/hb/logInfo/controller/LogInfoServlet.java
@@ -0,0 +1,51 @@
+package com.inks.hb.logInfo.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.common.PojotoGson;
+import com.inks.hb.logInfo.pojo.LogInfo;
+import com.inks.hb.logInfo.service.LogInfoService;
+import com.inks.hb.logInfo.service.LogInfoServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+
+@WebServlet(name = "LogInfoServlet", value = "/LogInfoServlet")
+public class LogInfoServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+
+ int page = Integer.parseInt(request.getParameter("page")); // 当前页码
+ int limit = Integer.parseInt(request.getParameter("limit")); // 每页的数据量
+ int make = Integer.parseInt(request.getParameter("make"));
+
+ // 调用service
+ LogInfoService service = new LogInfoServiceImpl();
+
+ // 默认输出信息
+ String code = "0"; //状态码
+ String msg = "数据查询正常"; //状态信息
+ String count; //数据总数
+ ArrayList list; //数据内容
+ if (make == 1) { //删除
+ int logId = Integer.parseInt(request.getParameter("logId"));
+ service.deleteLogInfo(logId);
+ }
+
+ count = String.valueOf(service.queryLogInfoNum());
+ list = service.query(page, limit);
+
+ PrintWriter out = response.getWriter();
+ out.print(new Gson().toJson(new PojotoGson(code, msg, count, list)));
+ }
+}
diff --git a/src/main/java/com/inks/hb/logInfo/dao/LogInfoDao.java b/src/main/java/com/inks/hb/logInfo/dao/LogInfoDao.java
new file mode 100644
index 0000000..b880bde
--- /dev/null
+++ b/src/main/java/com/inks/hb/logInfo/dao/LogInfoDao.java
@@ -0,0 +1,114 @@
+package com.inks.hb.logInfo.dao;
+
+import com.inks.hb.common.CommonDao;
+import com.inks.hb.common.DBUtil;
+import com.inks.hb.logInfo.pojo.LogInfo;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+public class LogInfoDao implements CommonDao {
+ @Override
+ public void insertData(Object o) throws SQLException {
+ LogInfo logInfo = (LogInfo) o;
+
+ Connection conn = DBUtil.getConnection();
+ String sql = "INSERT INTO logInfo (logName, loginId,loginName, logDate) VALUE (?,?,?,?)";
+ PreparedStatement ps = conn.prepareStatement(sql);
+ ps.setString(1, logInfo.getLogName());
+ ps.setInt(2, logInfo.getLoginId());
+ ps.setString(3, logInfo.getLoginName());
+ ps.setString(4, logInfo.getLogDate());
+
+ ps.executeUpdate();
+ ps.close();
+ }
+
+ @Override
+ public void deleteData(Object o) throws SQLException {
+ LogInfo logInfo = (LogInfo) o;
+
+ Connection conn = DBUtil.getConnection();
+ String sql = "DELETE FROM logInfo WHERE logId = ?";
+ PreparedStatement ps = conn.prepareStatement(sql);
+ ps.setInt(1, logInfo.getLogId());
+
+ ps.executeUpdate();
+ ps.close();
+ }
+
+ @Override
+ public void updateData(Object o) throws SQLException {
+
+ }
+
+ @Override
+ public int queryDataNum() throws SQLException {
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "select count(*) from logInfo;";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ ResultSet rs = pstmt.executeQuery();
+
+ int num;
+ if (rs.next()) num = rs.getInt("count(*)");
+ else num = 0;
+
+ rs.close();
+ pstmt.close();
+
+ return num;
+ }
+
+ @Override
+ public ArrayList query(int start, int length) throws SQLException {
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "select * from logInfo limit ?, ?;";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setInt(1, start - 1);
+ pstmt.setInt(2, length);
+ ResultSet rs = pstmt.executeQuery();
+
+ ArrayList list = new ArrayList<>();
+ LogInfo logInfo;
+
+ while (rs.next()) {
+ logInfo = new LogInfo(rs.getInt(1), rs.getString(2),
+ rs.getInt(3), rs.getString(4), rs.getString(5));
+ list.add(logInfo);
+ }
+
+ rs.close();
+ pstmt.close();
+
+ return list;
+ }
+
+ @Override
+ public Object query(Object o) throws SQLException {
+ return null;
+ }
+
+ public ArrayList queryName(int loginId) throws SQLException {
+ Connection conn = DBUtil.getConnection();
+ String sql = "SELECT * FROM logInfo WHERE loginId = ?";
+ PreparedStatement ps = conn.prepareStatement(sql);
+ ps.setInt(1, loginId);
+ ResultSet rs = ps.executeQuery();
+ ArrayList list = new ArrayList<>();
+ LogInfo logInfo;
+ while (rs.next()) {
+ logInfo = new LogInfo(rs.getInt(1), rs.getString(2),
+ rs.getInt(3), rs.getString(4), rs.getString(5));
+ list.add(logInfo);
+ }
+ rs.close();
+ ps.close();
+ return list;
+ }
+}
diff --git a/src/main/java/com/inks/hb/logInfo/pojo/LogInfo.java b/src/main/java/com/inks/hb/logInfo/pojo/LogInfo.java
new file mode 100644
index 0000000..56986ce
--- /dev/null
+++ b/src/main/java/com/inks/hb/logInfo/pojo/LogInfo.java
@@ -0,0 +1,96 @@
+package com.inks.hb.logInfo.pojo;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class LogInfo {
+
+ private int logId;
+
+ private String logName;
+
+ private int loginId;
+
+ private String loginName;
+
+ private String logDate;
+
+ private Date date;
+
+ private SimpleDateFormat dateFormat;
+
+ public LogInfo() {
+ super();
+ }
+
+ /**
+ * 此构造器呀
+ */
+ public LogInfo(String logName, int loginId, String loginName) {
+ this.logName = logName;
+ this.loginId = loginId;
+ this.loginName = loginName;
+ date = new Date();
+ dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ logDate = dateFormat.format(date);
+ }
+
+ public LogInfo(int logId, String logName, int loginId, String loginName, String logDate) {
+ this.logId = logId;
+ this.logName = logName;
+ this.loginId = loginId;
+ this.loginName = loginName;
+ this.logDate = logDate;
+ }
+
+ public int getLogId() {
+ return logId;
+ }
+
+ public void setLogId(int logId) {
+ this.logId = logId;
+ }
+
+ public String getLogName() {
+ return logName;
+ }
+
+ public void setLogName(String logName) {
+ this.logName = logName;
+ }
+
+ public int getLoginId() {
+ return loginId;
+ }
+
+ public void setLoginId(int loginId) {
+ this.loginId = loginId;
+ }
+
+ public String getLogDate() {
+ return logDate;
+ }
+
+ public void setLogDate(String logDate) {
+ this.logDate = logDate;
+ }
+
+ public String getLoginName() {
+ return loginName;
+ }
+
+ public void setLoginName(String loginName) {
+ this.loginName = loginName;
+ }
+
+ @Override
+ public String toString() {
+ return "LogInfo{" +
+ "logId=" + logId +
+ ", logName='" + logName + '\'' +
+ ", loginId=" + loginId +
+ ", loginName='" + loginName + '\'' +
+ ", logDate='" + logDate + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/com/inks/hb/logInfo/service/LogInfoService.java b/src/main/java/com/inks/hb/logInfo/service/LogInfoService.java
new file mode 100644
index 0000000..b11423d
--- /dev/null
+++ b/src/main/java/com/inks/hb/logInfo/service/LogInfoService.java
@@ -0,0 +1,19 @@
+package com.inks.hb.logInfo.service;
+
+import com.inks.hb.logInfo.pojo.LogInfo;
+
+import java.util.ArrayList;
+
+public interface LogInfoService {
+
+ int insertLogInfo(LogInfo logInfo);
+
+ int deleteLogInfo(int logId);
+
+ ArrayList query(int page, int limit);
+
+ int queryLogInfoNum();
+
+ int deleteByName(int loginId);
+
+}
diff --git a/src/main/java/com/inks/hb/logInfo/service/LogInfoServiceImpl.java b/src/main/java/com/inks/hb/logInfo/service/LogInfoServiceImpl.java
new file mode 100644
index 0000000..871f36f
--- /dev/null
+++ b/src/main/java/com/inks/hb/logInfo/service/LogInfoServiceImpl.java
@@ -0,0 +1,90 @@
+package com.inks.hb.logInfo.service;
+
+import com.inks.hb.logInfo.dao.LogInfoDao;
+import com.inks.hb.logInfo.pojo.LogInfo;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+public class LogInfoServiceImpl implements LogInfoService {
+
+ private LogInfoDao dao = new LogInfoDao();
+
+ /**
+ * 这里接收包装好的对象
+ *
+ * @param logInfo 日志
+ * @return 状态码 0失败 1成功
+ */
+ @Override
+ public int insertLogInfo(LogInfo logInfo) {
+ int check = 0;
+
+ try {
+ dao.insertData(logInfo);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ return 0;
+ }
+ return 1;
+ }
+
+ /**
+ * 删除
+ *
+ * @param logId 主键
+ * @return 状态码 1成功 0失败
+ */
+ @Override
+ public int deleteLogInfo(int logId) {
+
+ LogInfo logInfo = new LogInfo();
+ logInfo.setLogId(logId);
+
+ try {
+ dao.deleteData(logInfo);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ return 0;
+ }
+ return 1;
+ }
+
+ @Override
+ public ArrayList query(int page, int limit) {
+ int start = (page * limit) - limit + 1; //每一页的起始位置
+
+ if (start < 1) //小于1的话会触发一个错误
+ start = 1; //但是理论上page和limit是由table表格生成的参数
+
+ try {
+ return dao.query(start, limit);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return null;
+ }
+ }
+
+ @Override
+ public int queryLogInfoNum() {
+ try {
+ return dao.queryDataNum();
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return -1;
+ }
+ }
+
+ @Override
+ public int deleteByName(int loginId) {
+ try {
+ ArrayList list = dao.queryName(loginId);
+ for (LogInfo logInfo : list)
+ dao.deleteData(logInfo);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ return -1;
+ }
+ return 1;
+ }
+}
diff --git a/src/main/java/com/inks/hb/login/controller/InsertLoginServlet.java b/src/main/java/com/inks/hb/login/controller/InsertLoginServlet.java
new file mode 100644
index 0000000..ce0b618
--- /dev/null
+++ b/src/main/java/com/inks/hb/login/controller/InsertLoginServlet.java
@@ -0,0 +1,40 @@
+package com.inks.hb.login.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.login.pojo.Login;
+import com.inks.hb.login.service.LoginService;
+import com.inks.hb.login.service.LoginServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+@WebServlet(name = "InsertLoginServlet", value = "/InsertLoginServlet")
+public class InsertLoginServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("application/json; charset=utf-8");
+
+ // 获取前端传递的json数据
+ BufferedReader reader = request.getReader();
+ String json = reader.readLine();
+
+ // 解析json
+ Gson gson = new Gson();
+ Login login = gson.fromJson(json, Login.class);
+
+ LoginService service = new LoginServiceImpl();
+ int code = service.insertLogin(login);
+
+ PrintWriter out = response.getWriter();
+ out.print(gson.toJson(code));
+ }
+}
diff --git a/src/main/java/com/inks/hb/login/controller/LoginExcelServlet.java b/src/main/java/com/inks/hb/login/controller/LoginExcelServlet.java
new file mode 100644
index 0000000..05a5bb9
--- /dev/null
+++ b/src/main/java/com/inks/hb/login/controller/LoginExcelServlet.java
@@ -0,0 +1,33 @@
+package com.inks.hb.login.controller;
+
+import com.inks.hb.common.ExportExcel;
+import com.inks.hb.login.pojo.Login;
+import com.inks.hb.login.service.LoginService;
+import com.inks.hb.login.service.LoginServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+
+@WebServlet(name = "LoginExcelServlet", value = "/LoginExcelServlet")
+public class LoginExcelServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
+
+ LoginService service = new LoginServiceImpl();
+
+ ArrayList infoArrayList;
+ infoArrayList = service.query(1, service.queryLoginNum());
+
+ String[] headers = {"用户ID", "用户登录名", "用户密码", "用户昵称", "用户权限"};
+ String fileName = "用户信息";
+
+ ExportExcel ee = new ExportExcel<>();
+ ee.exportExcel(headers, infoArrayList, fileName, response);
+ }
+}
diff --git a/src/main/java/com/inks/hb/login/controller/LoginTableServlet.java b/src/main/java/com/inks/hb/login/controller/LoginTableServlet.java
new file mode 100644
index 0000000..388c5b2
--- /dev/null
+++ b/src/main/java/com/inks/hb/login/controller/LoginTableServlet.java
@@ -0,0 +1,55 @@
+package com.inks.hb.login.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.common.PojotoGson;
+import com.inks.hb.logInfo.service.LogInfoServiceImpl;
+import com.inks.hb.login.pojo.Login;
+import com.inks.hb.login.service.LoginService;
+import com.inks.hb.login.service.LoginServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+
+@WebServlet(name = "LoginTableServlet", value = "/LoginTableServlet")
+public class LoginTableServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ PrintWriter out = response.getWriter();
+
+ int page = Integer.parseInt(request.getParameter("page")); // 当前页码
+ int limit = Integer.parseInt(request.getParameter("limit")); // 每页的数据量
+ int make = Integer.parseInt(request.getParameter("make")); //状态标志
+
+ LoginService service = new LoginServiceImpl();
+
+ String code = "0"; //状态码
+ String msg = "数据查询正常"; //状态信息
+ String count; //数据总数
+ ArrayList list; //数据内容
+
+ if (make == 4) { //删除
+ int loginId = Integer.parseInt(request.getParameter("loginId"));
+ new LogInfoServiceImpl().deleteByName(loginId);
+ service.deleteLogin(loginId);
+ }
+
+ list = service.query(page, limit);
+ count = String.valueOf(service.queryLoginNum());
+
+
+ PojotoGson pojotoGson = new PojotoGson(code, msg, count, list);
+ Gson gson = new Gson();
+ out.print(gson.toJson(pojotoGson));
+ }
+}
diff --git a/src/main/java/com/inks/hb/login/controller/QueryLoginInfoServlet.java b/src/main/java/com/inks/hb/login/controller/QueryLoginInfoServlet.java
new file mode 100644
index 0000000..2129b61
--- /dev/null
+++ b/src/main/java/com/inks/hb/login/controller/QueryLoginInfoServlet.java
@@ -0,0 +1,48 @@
+package com.inks.hb.login.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.login.pojo.Login;
+import com.inks.hb.login.service.LoginService;
+import com.inks.hb.login.service.LoginServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.SQLException;
+
+/**
+ * 此servlet是根据登录名返回login对象,这个对象是包含密码数据的
+ * 所以为了安全,将servlet也放入了过滤器的过滤范围
+ */
+@WebServlet(value = "/QueryLoginInfoServlet", name = "QueryLoginInfoServlet")
+public class QueryLoginInfoServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ PrintWriter out = response.getWriter();
+
+ // 调用service
+ LoginService service = new LoginServiceImpl();
+
+ // 对于此功能,就直接从session中取值
+ HttpSession session = request.getSession();
+ String loginName = (String) session.getAttribute("LoginName");
+
+ try {
+ Login login = service.queryLogin(loginName);
+ Gson gson = new Gson();
+ out.print(gson.toJson(login));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/com/inks/hb/login/controller/QueryLoginNameServlet.java b/src/main/java/com/inks/hb/login/controller/QueryLoginNameServlet.java
new file mode 100644
index 0000000..4fed588
--- /dev/null
+++ b/src/main/java/com/inks/hb/login/controller/QueryLoginNameServlet.java
@@ -0,0 +1,63 @@
+package com.inks.hb.login.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.common.MD5;
+import com.inks.hb.logInfo.pojo.LogInfo;
+import com.inks.hb.logInfo.service.LogInfoService;
+import com.inks.hb.logInfo.service.LogInfoServiceImpl;
+import com.inks.hb.login.pojo.Login;
+import com.inks.hb.login.service.LoginService;
+import com.inks.hb.login.service.LoginServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.SQLException;
+
+/**
+ * 此servlet是登录界面使用的,根据用户登录名和用户密码进行登录判断。
+ * 如果登录结果判断成功就在session中写入当前的登录名值
+ * 通过ajax返回给判断的结果。
+ */
+@WebServlet(value = "/QueryLoginNameServlet", name = "QueryLoginNameServlet")
+public class QueryLoginNameServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ PrintWriter out = response.getWriter();
+
+ // 调用service
+ LoginService service = new LoginServiceImpl();
+ MD5 md5 = new MD5();
+
+ // 获得姓名
+ String loginName = request.getParameter("loginName");
+ String loginPwd = md5.getMD5(request.getParameter("loginPwd")); //转成MD5存储
+
+ try {
+ int check = service.queryByName(loginName, loginPwd);
+ if (check == 1) { // 设置session
+ HttpSession session = request.getSession();
+ session.setAttribute("LoginName", loginName);
+ Login login = service.queryLogin(loginName);
+ //写入登录记录
+ LogInfo logInfo = new LogInfo("登录", login.getLoginId(), login.getLoginName());
+ LogInfoService logInfoService = new LogInfoServiceImpl();
+ logInfoService.insertLogInfo(logInfo);
+ }
+ Gson gson = new Gson();
+ out.print(gson.toJson(check));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/com/inks/hb/login/controller/UpdatePwdServlet.java b/src/main/java/com/inks/hb/login/controller/UpdatePwdServlet.java
new file mode 100644
index 0000000..3f42ad0
--- /dev/null
+++ b/src/main/java/com/inks/hb/login/controller/UpdatePwdServlet.java
@@ -0,0 +1,53 @@
+package com.inks.hb.login.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.common.MD5;
+import com.inks.hb.login.pojo.Login;
+import com.inks.hb.login.service.LoginService;
+import com.inks.hb.login.service.LoginServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.SQLException;
+
+@WebServlet(name = "UpdatePwdServlet", value = "/UpdatePwdServlet")
+public class UpdatePwdServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ PrintWriter out = response.getWriter();
+
+ // 调用service
+ LoginService service = new LoginServiceImpl();
+ MD5 md5 = new MD5();
+
+ // 获得姓名
+ String loginName = request.getParameter("loginName");
+ String loginPwd = request.getParameter("loginPwd"); //转成MD5存储
+
+ Login login;
+ int check = -1;
+
+ try {
+ login = service.queryLogin(loginName);
+ System.out.println(login);
+ login.setLoginPwd(loginPwd);
+ System.out.println(login);
+ check = service.updateLogin(login);
+ System.out.println(check);
+ System.out.println(service.queryLogin(loginName));
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ Gson gson = new Gson();
+ out.print(gson.toJson(check));
+ }
+}
diff --git a/src/main/java/com/inks/hb/login/controller/UploadFileServlet.java b/src/main/java/com/inks/hb/login/controller/UploadFileServlet.java
new file mode 100644
index 0000000..298c772
--- /dev/null
+++ b/src/main/java/com/inks/hb/login/controller/UploadFileServlet.java
@@ -0,0 +1,24 @@
+package com.inks.hb.login.controller;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+@WebServlet(name = "UploadFileServlet", value = "/UploadFileServlet")
+public class UploadFileServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ PrintWriter out = response.getWriter();
+
+
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ this.doPost(request, response);
+ }
+}
diff --git a/src/main/java/com/inks/hb/login/dao/LoginDao.java b/src/main/java/com/inks/hb/login/dao/LoginDao.java
new file mode 100644
index 0000000..0c31de6
--- /dev/null
+++ b/src/main/java/com/inks/hb/login/dao/LoginDao.java
@@ -0,0 +1,131 @@
+package com.inks.hb.login.dao;
+
+import com.inks.hb.common.CommonDao;
+import com.inks.hb.common.DBUtil;
+import com.inks.hb.login.pojo.Login;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+public class LoginDao implements CommonDao {
+
+ @Override
+ public void insertData(Object o) throws SQLException {
+
+ Login login = (Login) o;
+
+ Connection conn = DBUtil.getConnection();
+ String sql = "INSERT INTO login (loginName, loginPwd, loginNickName, loginAdmin) VALUE (?,?,?,?)";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, login.getLoginName());
+ pstmt.setString(2, login.getLoginPwd());
+ pstmt.setString(3, login.getLoginNickName());
+ pstmt.setInt(4, login.getLoginAdmin());
+
+ pstmt.executeUpdate();
+ pstmt.close();
+ }
+
+ @Override
+ public void deleteData(Object o) throws SQLException {
+ Login login = (Login) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "DELETE FROM login WHERE loginId = ?";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setInt(1, login.getLoginId());
+
+ pstmt.executeUpdate();
+ pstmt.close();
+ }
+
+ @Override
+ public void updateData(Object o) throws SQLException {
+ Login login = (Login) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "UPDATE login SET loginName = ? ,loginPwd = ?,loginNickName = ?,loginAdmin = ? WHERE loginId = ?";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, login.getLoginName());
+ pstmt.setString(2, login.getLoginPwd());
+ pstmt.setString(3, login.getLoginNickName());
+ pstmt.setInt(4, login.getLoginAdmin());
+ pstmt.setInt(5, login.getLoginId());
+
+ pstmt.executeUpdate();
+ pstmt.close();
+ }
+
+ @Override
+ public int queryDataNum() throws SQLException {
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "select count(*) from login;";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ ResultSet rs = pstmt.executeQuery();
+
+ int num;
+ if (rs.next()) num = rs.getInt("count(*)");
+ else num = 0;
+
+ rs.close();
+ pstmt.close();
+
+ return num;
+ }
+
+ @Override
+ public ArrayList query(int start, int length) throws SQLException {
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "select * from login limit ?, ?;";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setInt(1, start - 1);
+ pstmt.setInt(2, length);
+ ResultSet rs = pstmt.executeQuery();
+
+ ArrayList list = new ArrayList<>();
+ Login login;
+
+ while (rs.next()) {
+ login = new Login(rs.getInt(1), rs.getString(2),
+ rs.getString(3), rs.getString(4), rs.getInt(5));
+ list.add(login);
+ }
+
+ rs.close();
+ pstmt.close();
+
+ return list;
+ }
+
+ @Override
+ public Object query(Object o) throws SQLException {
+
+ Login login = (Login) o;
+
+ Connection conn = DBUtil.getConnection();
+ String sql = "SELECT * FROM login WHERE loginName = ?";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, login.getLoginName());
+ ResultSet rs = pstmt.executeQuery();
+
+ Login loginer = new Login();
+ if (rs.next()) {
+ loginer = new Login(rs.getInt(1), rs.getString(2),
+ rs.getString(3), rs.getString(4), rs.getInt(5));
+ }
+
+ rs.close();
+ pstmt.close();
+
+ return loginer;
+ }
+}
diff --git a/src/main/java/com/inks/hb/login/pojo/Login.java b/src/main/java/com/inks/hb/login/pojo/Login.java
new file mode 100644
index 0000000..2d997d5
--- /dev/null
+++ b/src/main/java/com/inks/hb/login/pojo/Login.java
@@ -0,0 +1,96 @@
+package com.inks.hb.login.pojo;
+
+/**
+ * Login对象对应数据库中的login表,主键为authId,设置为自动增加。
+ */
+public class Login {
+
+ private int loginId; //用户ID
+
+ private String loginName; //用户登录名
+
+ private String loginPwd; //用户密码
+
+ private String loginNickName; //用户昵称
+
+ private int loginAdmin; //用户权限
+
+ public Login() {
+ super();
+ loginAdmin = -1;
+ }
+
+ public Login(String loginName) {
+ this.loginName = loginName;
+ }
+
+ public Login(String loginName, String loginPwd) {
+ this.loginName = loginName;
+ this.loginPwd = loginPwd;
+ }
+
+ public Login(String loginName, String loginPwd, String loginNickName) {
+ this.loginName = loginName;
+ this.loginPwd = loginPwd;
+ this.loginNickName = loginNickName;
+ }
+
+ public Login(int loginId, String loginName, String loginPwd, String loginNickName, int loginAdmin) {
+ this.loginId = loginId;
+ this.loginName = loginName;
+ this.loginPwd = loginPwd;
+ this.loginNickName = loginNickName;
+ this.loginAdmin = loginAdmin;
+ }
+
+ public int getLoginId() {
+ return loginId;
+ }
+
+ public void setLoginId(int loginId) {
+ this.loginId = loginId;
+ }
+
+ public String getLoginName() {
+ return loginName;
+ }
+
+ public void setLoginName(String loginName) {
+ this.loginName = loginName;
+ }
+
+ public String getLoginPwd() {
+ return loginPwd;
+ }
+
+ public void setLoginPwd(String loginPwd) {
+ this.loginPwd = loginPwd;
+ }
+
+ public String getLoginNickName() {
+ return loginNickName;
+ }
+
+ public void setLoginNickName(String loginNickName) {
+ this.loginNickName = loginNickName;
+ }
+
+ public int getLoginAdmin() {
+ return loginAdmin;
+ }
+
+ public void setLoginAdmin(int loginAdmin) {
+ this.loginAdmin = loginAdmin;
+ }
+
+ @Override
+ public String toString() {
+ return "Login{" +
+ "loginId=" + loginId +
+ ", loginName='" + loginName + '\'' +
+ ", loginPwd='" + loginPwd + '\'' +
+ ", loginNickName='" + loginNickName + '\'' +
+ ", loginAdmin=" + loginAdmin +
+ '}';
+ }
+}
diff --git a/src/main/java/com/inks/hb/login/service/LoginService.java b/src/main/java/com/inks/hb/login/service/LoginService.java
new file mode 100644
index 0000000..5a78870
--- /dev/null
+++ b/src/main/java/com/inks/hb/login/service/LoginService.java
@@ -0,0 +1,47 @@
+package com.inks.hb.login.service;
+
+import com.inks.hb.login.pojo.Login;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+/**
+ * LoginService
+ */
+public interface LoginService {
+
+ /**
+ * 根据name和pwd返回判断结果
+ *
+ * @param name 登录名
+ * @param pwd 登录密码
+ * @return 0:密码错误;1:登录成功;-1:账户不存在
+ * @throws SQLException 数据库错误
+ */
+ int queryByName(String name, String pwd) throws SQLException;
+
+ /**
+ * 根据name返回Login对象
+ *
+ * @param name 登录名
+ * @return Login对象
+ * @throws SQLException 数据库错误
+ */
+ Login queryLogin(String name) throws SQLException;
+
+ //增添
+ int insertLogin(Login login);
+
+ //删除
+ int deleteLogin(int loginId);
+
+ //更新
+ int updateLogin(Login login);
+
+ //查询多条
+ ArrayList query(int page, int limit);
+
+ //查询长度
+ int queryLoginNum();
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/inks/hb/login/service/LoginServiceImpl.java b/src/main/java/com/inks/hb/login/service/LoginServiceImpl.java
new file mode 100644
index 0000000..763b826
--- /dev/null
+++ b/src/main/java/com/inks/hb/login/service/LoginServiceImpl.java
@@ -0,0 +1,107 @@
+package com.inks.hb.login.service;
+
+import com.inks.hb.common.MD5;
+import com.inks.hb.login.dao.LoginDao;
+import com.inks.hb.login.pojo.Login;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+public class LoginServiceImpl implements LoginService {
+
+ private LoginDao dao = new LoginDao();
+
+ private MD5 md5 = new MD5();
+
+ @Override
+ public int queryByName(String name, String pwd) throws SQLException {
+ Login loginQuery = new Login(name, pwd);
+ Login login = (Login) dao.query(loginQuery);
+ int check = 0; //密码错误
+ if (login.getLoginId() == 0)
+ check = -1; //账户不存在
+ else if (login.getLoginPwd().equals(pwd))
+ check = 1; //登录成功
+
+ return check;
+ }
+
+ @Override
+ public Login queryLogin(String name) throws SQLException {
+
+ Login loginQuery = new Login();
+ loginQuery.setLoginName(name);
+
+ return (Login) dao.query(loginQuery);
+ }
+
+ @Override
+ public int insertLogin(Login login) {
+
+ //密码转MD5加密存储
+ String pwd = login.getLoginPwd();
+ login.setLoginPwd(md5.getMD5(pwd));
+
+ try {
+ dao.insertData(login);
+ } catch (SQLException e) {
+ return -1;
+ }
+ return 1;
+ }
+
+ @Override
+ public int deleteLogin(int loginId) {
+ Login login = new Login();
+ login.setLoginId(loginId);
+
+ try {
+ dao.deleteData(login);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ return -1;
+ }
+ return 1;
+ }
+
+ @Override
+ public int updateLogin(Login login) {
+
+ String pwd = login.getLoginPwd();
+ login.setLoginPwd(md5.getMD5(pwd));
+
+ try {
+ dao.updateData(login);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ return -1;
+ }
+ return 1;
+ }
+
+ @Override
+ public ArrayList query(int page, int limit) {
+ int start = (page * limit) - limit + 1; //每一页的起始位置
+
+ if (start < 1) //小于1的话会触发一个错误
+ start = 1; //但是理论上page和limit是由table表格生成的参数
+
+ try {
+ return dao.query(start, limit);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return null;
+ }
+ }
+
+ @Override
+ public int queryLoginNum() {
+ try {
+ return dao.queryDataNum();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return 0;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/inks/hb/orderinfo/controller/InsertAndUpdateServlet.java b/src/main/java/com/inks/hb/orderinfo/controller/InsertAndUpdateServlet.java
new file mode 100644
index 0000000..2df65d7
--- /dev/null
+++ b/src/main/java/com/inks/hb/orderinfo/controller/InsertAndUpdateServlet.java
@@ -0,0 +1,75 @@
+package com.inks.hb.orderinfo.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.login.pojo.Login;
+import com.inks.hb.orderinfo.pojo.OrderInfo;
+import com.inks.hb.orderinfo.service.OrderInfoService;
+import com.inks.hb.orderinfo.service.OrderInfoServiceImpl;
+import com.inks.hb.roomtype.pojo.RoomType;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+@WebServlet(name = "InsertAndUpdateServlet", value = "/InsertAndUpdateServlet")
+public class InsertAndUpdateServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ PrintWriter out = response.getWriter();
+
+ OrderInfoService service = new OrderInfoServiceImpl();
+
+ String orderId = request.getParameter("orderId"); //1
+ String orderName = request.getParameter("orderName"); //2
+ String orderPhone = request.getParameter("orderPhone"); //3
+ String orderIDcard = request.getParameter("orderIDcard"); //4
+ RoomType typeId = new RoomType(request.getParameter("typeId")); //5
+ String arrireDate = request.getParameter("arrireDate"); //6
+ String leaveDate = request.getParameter("leaveDate"); //7
+ String orderState = request.getParameter("orderState"); //8
+ String checkNum = request.getParameter("checkNum"); //9
+ String roomId = ""; //10
+ String price = request.getParameter("price"); //11
+ String checkPrice = request.getParameter("checkPrice"); //12
+ String discountReason = request.getParameter("discountReason"); //14
+ String addBed = request.getParameter("addBed"); //15
+ String addBedPrice = request.getParameter("addBedPrice"); //16
+ String orderMoney = request.getParameter("orderMoney"); //17
+ String remark = request.getParameter("remark"); //18
+ Login operatorId = new Login(request.getParameter("operatorId")); //19
+ int make = Integer.parseInt(request.getParameter("make")); // 20 标志啊
+
+ int discount;
+
+ try { //对折扣值为空的处理
+ discount = Integer.parseInt(request.getParameter("discount")); //13
+ } catch (NumberFormatException e) {
+ discount = 0;
+ }
+
+ OrderInfo orderInfo = new OrderInfo(orderId, orderName, orderPhone, orderIDcard, typeId, arrireDate, leaveDate, orderState, checkNum, roomId, price, checkPrice, discount, discountReason, addBed, addBedPrice, orderMoney, remark, operatorId);
+
+ int code = -1; //返回的状态
+
+ if (make == 1) { //1.新增
+ code = service.insertOrderInfo(orderInfo);
+ } else if (make == 2) { //修改
+ code = service.updateOrderInfo(orderInfo);
+ }
+
+
+ //make=1 -> 1:插入成功 0:存在同名项 -1:插入失败
+ //make=2 -> 1:修改成功 -1;修改失败
+ Gson gson = new Gson();
+ out.print(gson.toJson(code));
+ }
+}
diff --git a/src/main/java/com/inks/hb/orderinfo/controller/OrderInfoExcelServlet.java b/src/main/java/com/inks/hb/orderinfo/controller/OrderInfoExcelServlet.java
new file mode 100644
index 0000000..1310930
--- /dev/null
+++ b/src/main/java/com/inks/hb/orderinfo/controller/OrderInfoExcelServlet.java
@@ -0,0 +1,51 @@
+package com.inks.hb.orderinfo.controller;
+
+import com.inks.hb.common.ExportExcel;
+import com.inks.hb.orderinfo.pojo.OrderInfo;
+import com.inks.hb.orderinfo.pojo.OrderToTable;
+import com.inks.hb.orderinfo.service.OrderInfoService;
+import com.inks.hb.orderinfo.service.OrderInfoServiceImpl;
+import com.inks.hb.roomtype.service.RoomTypeService;
+import com.inks.hb.roomtype.service.RoomTypeServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+
+@WebServlet(name = "OrderInfoExcelServlet", value = "/OrderInfoExcelServlet")
+public class OrderInfoExcelServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
+
+ OrderInfoService service = new OrderInfoServiceImpl();
+ RoomTypeService roomTypeService = new RoomTypeServiceImpl();
+
+ ArrayList infoArrayList = service.query(1, service.queryOrderInfoNum());
+
+ ArrayList list = new ArrayList<>(); //转成可使用
+
+ OrderToTable toTable;
+
+ for (OrderInfo orderInfo : infoArrayList) { //转换成前端界面可接收的类型 主要是转 房间类型 和操作员
+ toTable = new OrderToTable(orderInfo.getOrderId(), orderInfo.getOrderName(), orderInfo.getOrderPhone()
+ , orderInfo.getOrderIDcard(), orderInfo.getArrireDate(), orderInfo.getLeaveDate()
+ , roomTypeService.query(orderInfo.getTypeId().getTypeId()).getTypeName()
+ , orderInfo.getCheckNum(), orderInfo.getPrice(), orderInfo.getCheckPrice()
+ , orderInfo.getDiscount(), orderInfo.getDiscountReason(), orderInfo.getAddBed()
+ , orderInfo.getAddBedPrice(), orderInfo.getOrderMoney(), orderInfo.getOrderState()
+ , orderInfo.getRemark(), orderInfo.getOperatorId().getLoginName());
+ list.add(toTable);
+ }
+
+ String[] headers = {"预订单号", "预定人", "联系电话", "身份证", "抵店时间", "离店时间", "房间类型", "入住人数", "客房价格", "入住价格", "折扣", "折扣原因", "是否加床", "加床价格", "预收款", "单据状态", "备注", "操作员"};
+ String fileName = "预订单信息";
+
+ ExportExcel ee = new ExportExcel<>();
+ ee.exportExcel(headers, list, fileName, response);
+ }
+}
diff --git a/src/main/java/com/inks/hb/orderinfo/controller/OrderInfoServlet.java b/src/main/java/com/inks/hb/orderinfo/controller/OrderInfoServlet.java
new file mode 100644
index 0000000..3c57ed5
--- /dev/null
+++ b/src/main/java/com/inks/hb/orderinfo/controller/OrderInfoServlet.java
@@ -0,0 +1,85 @@
+package com.inks.hb.orderinfo.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.common.PojotoGson;
+import com.inks.hb.orderinfo.pojo.OrderInfo;
+import com.inks.hb.orderinfo.pojo.OrderToTable;
+import com.inks.hb.orderinfo.service.OrderInfoService;
+import com.inks.hb.orderinfo.service.OrderInfoServiceImpl;
+import com.inks.hb.roomtype.service.RoomTypeService;
+import com.inks.hb.roomtype.service.RoomTypeServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+
+@WebServlet(name = "OrderInfoServlet", value = "/OrderInfoServlet")
+public class OrderInfoServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ PrintWriter out = response.getWriter();
+
+ int page = Integer.parseInt(request.getParameter("page")); // 当前页码
+ int limit = Integer.parseInt(request.getParameter("limit")); // 每页的数据量
+ int make = Integer.parseInt(request.getParameter("make")); //状态标志
+
+ // 调用service
+ OrderInfoService service = new OrderInfoServiceImpl();
+ RoomTypeService roomTypeService = new RoomTypeServiceImpl();
+
+ // 默认输出信息
+ String code = "0"; //状态码
+ String msg = "数据查询正常"; //状态信息
+ String count; //数据总数
+ ArrayList list = new ArrayList<>(); //数据内容
+ ArrayList toTablesList = new ArrayList<>(); //转成可使用
+ OrderToTable toTable;
+
+ //单个全局属性
+ String orderId; //预定单号
+ String select; //查询值
+
+ //获取对应状态属性
+ if (make == 1 || make == 2) { //1和2这部分完全是相同的
+ select = request.getParameter("select");
+ list = service.queryOrder(make, select);
+ count = String.valueOf(list.size());
+ msg = "结果如下";
+ } else if (make == 4) {
+ orderId = request.getParameter("orderId");
+ if (service.deleteOrderInfo(orderId) == -1) {
+ msg = "删除失败";
+ code = "-1";
+ }
+ count = String.valueOf(service.queryOrderInfoNum());
+ } else {
+ list = service.query(page, limit);
+ count = String.valueOf(service.queryOrderInfoNum());
+ }
+
+ for (OrderInfo orderInfo : list) { //转换成前端界面可接收的类型 主要是转 房间类型 和操作员
+ toTable = new OrderToTable(orderInfo.getOrderId(), orderInfo.getOrderName(), orderInfo.getOrderPhone()
+ , orderInfo.getOrderIDcard(), orderInfo.getArrireDate(), orderInfo.getLeaveDate()
+ , roomTypeService.query(orderInfo.getTypeId().getTypeId()).getTypeName()
+ , orderInfo.getCheckNum(), orderInfo.getPrice(), orderInfo.getCheckPrice()
+ , orderInfo.getDiscount(), orderInfo.getDiscountReason(), orderInfo.getAddBed()
+ , orderInfo.getAddBedPrice(), orderInfo.getOrderMoney(), orderInfo.getOrderState()
+ , orderInfo.getRemark(), orderInfo.getOperatorId().getLoginName());
+ toTablesList.add(toTable);
+ }
+
+ PojotoGson pojotoGson = new PojotoGson(code, msg, count, toTablesList);
+ Gson gson = new Gson();
+ out.print(gson.toJson(pojotoGson));
+ }
+}
diff --git a/src/main/java/com/inks/hb/orderinfo/controller/QueryOrderInfoServlet.java b/src/main/java/com/inks/hb/orderinfo/controller/QueryOrderInfoServlet.java
new file mode 100644
index 0000000..e761107
--- /dev/null
+++ b/src/main/java/com/inks/hb/orderinfo/controller/QueryOrderInfoServlet.java
@@ -0,0 +1,44 @@
+package com.inks.hb.orderinfo.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.orderinfo.pojo.OrderInfo;
+import com.inks.hb.orderinfo.pojo.OrderToTable;
+import com.inks.hb.orderinfo.service.OrderInfoServiceImpl;
+import com.inks.hb.roomtype.service.RoomTypeServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+@WebServlet(name = "QueryOrderInfoServlet", value = "/QueryOrderInfoServlet")
+public class QueryOrderInfoServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ PrintWriter out = response.getWriter();
+
+ // 获取值
+ String orderId = request.getParameter("orderId");
+
+ OrderInfo orderInfo = new OrderInfoServiceImpl().query(orderId);
+
+ OrderToTable toTable = new OrderToTable(orderInfo.getOrderId(), orderInfo.getOrderName(), orderInfo.getOrderPhone()
+ , orderInfo.getOrderIDcard(), orderInfo.getArrireDate(), orderInfo.getLeaveDate()
+ , new RoomTypeServiceImpl().query(orderInfo.getTypeId().getTypeId()).getTypeId()
+ , orderInfo.getCheckNum(), orderInfo.getPrice(), orderInfo.getCheckPrice()
+ , orderInfo.getDiscount(), orderInfo.getDiscountReason(), orderInfo.getAddBed()
+ , orderInfo.getAddBedPrice(), orderInfo.getOrderMoney(), orderInfo.getOrderState()
+ , orderInfo.getRemark(), orderInfo.getOperatorId().getLoginName());
+
+ Gson gson = new Gson();
+ out.print(gson.toJson(toTable));
+ }
+}
diff --git a/src/main/java/com/inks/hb/orderinfo/dao/OrderInfoDao.java b/src/main/java/com/inks/hb/orderinfo/dao/OrderInfoDao.java
new file mode 100644
index 0000000..4d2d0f6
--- /dev/null
+++ b/src/main/java/com/inks/hb/orderinfo/dao/OrderInfoDao.java
@@ -0,0 +1,239 @@
+package com.inks.hb.orderinfo.dao;
+
+import com.inks.hb.common.CommonDao;
+import com.inks.hb.common.DBUtil;
+import com.inks.hb.login.pojo.Login;
+import com.inks.hb.orderinfo.pojo.OrderInfo;
+import com.inks.hb.roomtype.pojo.RoomType;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+/**
+ * 另提供queryOrder-> 对预定人名称和房间类型的查询
+ */
+public class OrderInfoDao implements CommonDao {
+
+ /**
+ * 插入函数关联内容如下:
+ * 1.外键关联: roomtype表
+ * 2.属性关联 login字段
+ * 3.pojo对象的无参构造函数
+ * String类型无赋值则其值为NULL
+ * Int类型为0
+ * typeId与operatorId需要负值对象
+ *
+ * @param o OrderInfo字段信息
+ * @throws SQLException 数据库
+ */
+ @Override
+ public void insertData(Object o) throws SQLException {
+ OrderInfo orderInfo = (OrderInfo) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "INSERT INTO orderinfo VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, orderInfo.getOrderId());
+ pstmt.setString(2, orderInfo.getOrderName());
+ pstmt.setString(3, orderInfo.getOrderPhone());
+ pstmt.setString(4, orderInfo.getOrderIDcard());
+ pstmt.setString(5, orderInfo.getTypeId().getTypeId());
+ pstmt.setString(6, orderInfo.getArrireDate());
+ pstmt.setString(7, orderInfo.getLeaveDate());
+ pstmt.setString(8, orderInfo.getOrderState());
+ pstmt.setString(9, orderInfo.getCheckNum());
+ pstmt.setString(10, orderInfo.getRoomId());
+ pstmt.setString(11, orderInfo.getPrice());
+ pstmt.setString(12, orderInfo.getCheckPrice());
+ pstmt.setInt(13, orderInfo.getDiscount());
+ pstmt.setString(14, orderInfo.getDiscountReason());
+ pstmt.setString(15, orderInfo.getAddBed());
+ pstmt.setString(16, orderInfo.getAddBedPrice());
+ pstmt.setString(17, orderInfo.getOrderMoney());
+ pstmt.setString(18, orderInfo.getRemark());
+ pstmt.setString(19, orderInfo.getOperatorId().getLoginName());
+
+ pstmt.executeUpdate();
+
+ pstmt.close();
+ }
+
+ @Override
+ public void deleteData(Object o) throws SQLException {
+ OrderInfo orderInfo = (OrderInfo) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "DELETE FROM orderinfo WHERE orderId = ?";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, orderInfo.getOrderId());
+
+ pstmt.executeUpdate();
+ pstmt.close();
+ }
+
+ @Override
+ public void updateData(Object o) throws SQLException {
+ OrderInfo orderInfo = (OrderInfo) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "UPDATE orderinfo SET orderName = ? ,orderPhone = ? ,orderIDcard = ? ,typeId = ? " +
+ ",arrireDate = ? ,leaveDate = ? ,orderState = ? ,checkNum = ? ,roomId = ? ,price = ? ,checkPrice = ? " +
+ ",discount = ? ,discountReason = ? ,addBed = ? ,addBedPrice = ? ,orderMoney = ? ,remark = ? " +
+ ",operatorId = ? WHERE orderId = ?";
+
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, orderInfo.getOrderName());
+ pstmt.setString(2, orderInfo.getOrderPhone());
+ pstmt.setString(3, orderInfo.getOrderIDcard());
+ pstmt.setString(4, orderInfo.getTypeId().getTypeId());
+ pstmt.setString(5, orderInfo.getArrireDate());
+ pstmt.setString(6, orderInfo.getLeaveDate());
+ pstmt.setString(7, orderInfo.getOrderState());
+ pstmt.setString(8, orderInfo.getCheckNum());
+ pstmt.setString(9, orderInfo.getRoomId());
+ pstmt.setString(10, orderInfo.getPrice());
+ pstmt.setString(11, orderInfo.getCheckPrice());
+ pstmt.setInt(12, orderInfo.getDiscount());
+ pstmt.setString(13, orderInfo.getDiscountReason());
+ pstmt.setString(14, orderInfo.getAddBed());
+ pstmt.setString(15, orderInfo.getAddBedPrice());
+ pstmt.setString(16, orderInfo.getOrderMoney());
+ pstmt.setString(17, orderInfo.getRemark());
+ pstmt.setString(18, orderInfo.getOperatorId().getLoginName());
+ pstmt.setString(19, orderInfo.getOrderId());
+
+ pstmt.executeUpdate();
+ pstmt.close();
+ }
+
+ @Override
+ public int queryDataNum() throws SQLException {
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "select count(*) from orderinfo;";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ ResultSet rs = pstmt.executeQuery();
+
+ int num;
+ if (rs.next()) num = rs.getInt("count(*)");
+ else num = 0;
+
+ rs.close();
+ pstmt.close();
+
+ return num;
+ }
+
+ @Override
+ public ArrayList query(int start, int length) throws SQLException {
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "select * from orderinfo limit ?, ?;";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setInt(1, start - 1);
+ pstmt.setInt(2, length);
+ ResultSet rs = pstmt.executeQuery();
+
+ ArrayList list = new ArrayList<>();
+ OrderInfo orderInfo;
+
+ while (rs.next()) {
+ orderInfo = new OrderInfo(rs.getString(1), rs.getString(2), rs.getString(3)
+ , rs.getString(4), new RoomType(rs.getString(5)), rs.getString(6)
+ , rs.getString(7), rs.getString(8), rs.getString(9)
+ , rs.getString(10), rs.getString(11), rs.getString(12)
+ , rs.getInt(13), rs.getString(14), rs.getString(15)
+ , rs.getString(16), rs.getString(17), rs.getString(18)
+ , new Login(rs.getString(19)));
+ list.add(orderInfo);
+ }
+
+ rs.close();
+ pstmt.close();
+
+ return list;
+ }
+
+ @Override
+ public Object query(Object o) throws SQLException {
+ OrderInfo orderInfoQuery = (OrderInfo) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ //根据ID的查询
+ String sql = "SELECT * FROM orderinfo WHERE orderId = ?";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, orderInfoQuery.getOrderId());
+ ResultSet rs = pstmt.executeQuery();
+
+ OrderInfo orderInfo = null;
+ while (rs.next()) {
+ orderInfo = new OrderInfo(rs.getString(1), rs.getString(2), rs.getString(3)
+ , rs.getString(4), new RoomType(rs.getString(5)), rs.getString(6)
+ , rs.getString(7), rs.getString(8), rs.getString(9)
+ , rs.getString(10), rs.getString(11), rs.getString(12)
+ , rs.getInt(13), rs.getString(14), rs.getString(15)
+ , rs.getString(16), rs.getString(17), rs.getString(18)
+ , new Login(rs.getString(19)));
+ }
+
+ if (orderInfo == null) {
+ orderInfo = new OrderInfo();
+ orderInfo.setNull(true);
+ }
+ rs.close();
+ pstmt.close();
+
+ return orderInfo;
+ }
+
+ /**
+ * 查询啊,模糊查询呀
+ *
+ * @param make 1:查名称 2:查类型
+ * @param select 待查的值
+ * @return 查询对象
+ * @throws SQLException 抛给业务层
+ */
+ public ArrayList queryOrder(int make, String select) throws SQLException {
+ Connection conn = DBUtil.getConnection();
+
+ String sql;
+ if (make == 1)
+ sql = "select * from orderinfo WHERE orderName LIKE ?;";
+ else
+ sql = "select * from orderinfo WHERE typeId LIKE ?;";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, "%" + select + "%");
+
+ ResultSet rs = pstmt.executeQuery();
+ ArrayList list = new ArrayList<>();
+ OrderInfo orderInfo;
+
+ while (rs.next()) {
+ orderInfo = new OrderInfo(rs.getString(1), rs.getString(2), rs.getString(3)
+ , rs.getString(4), new RoomType(rs.getString(5)), rs.getString(6)
+ , rs.getString(7), rs.getString(8), rs.getString(9)
+ , rs.getString(10), rs.getString(11), rs.getString(12)
+ , rs.getInt(13), rs.getString(14), rs.getString(15)
+ , rs.getString(16), rs.getString(17), rs.getString(18)
+ , new Login(rs.getString(19)));
+ list.add(orderInfo);
+ }
+
+ rs.close();
+ pstmt.close();
+
+ return list;
+ }
+
+}
diff --git a/src/main/java/com/inks/hb/orderinfo/pojo/OrderInfo.java b/src/main/java/com/inks/hb/orderinfo/pojo/OrderInfo.java
new file mode 100644
index 0000000..025df30
--- /dev/null
+++ b/src/main/java/com/inks/hb/orderinfo/pojo/OrderInfo.java
@@ -0,0 +1,263 @@
+package com.inks.hb.orderinfo.pojo;
+
+import com.inks.hb.login.pojo.Login;
+import com.inks.hb.roomtype.pojo.RoomType;
+
+/**
+ * 预订单
+ * 字段太多了,只提供空参构造器
+ */
+public class OrderInfo {
+
+ private String orderId; //预订单号->直接获取时间戳?存进去 1
+
+ private String orderName; //预定人 2
+
+ private String orderPhone; //联系电话 3
+
+ private String orderIDcard; // 4
+
+ private RoomType typeId; //房间类型->对应roomtype表 5<-------------------
+
+ private String arrireDate; //抵店时间 6
+
+ private String leaveDate; //离店时间 7
+
+ private String orderState; //单据状态->该字段前端做下拉框写死 8
+
+ private String checkNum; //入住人数 9
+
+ private String roomId; //客房编号->预订单不一定实际分配,预定转入住时才可以 10
+
+ private String price; //客房价格 11
+
+ private String checkPrice; //入住价格 12
+
+ private int discount; //折扣 13<-------------------
+
+ private String discountReason; //折扣原因 14
+
+ private String addBed; //是否加床 15
+
+ private String addBedPrice; //加床价格 16
+
+ private String orderMoney; //预收款 17
+
+ private String remark; //备注 18
+
+ private Login operatorId; //操作员->登录 19<-------------------
+
+ private boolean isNull; //是否为空值对象 20
+
+ public OrderInfo() {
+ super();
+ }
+
+ public OrderInfo(String orderId, String orderName, String orderPhone, String orderIDcard, RoomType typeId, String arrireDate, String leaveDate, String orderState, String checkNum, String roomId, String price, String checkPrice, int discount, String discountReason, String addBed, String addBedPrice, String orderMoney, String remark, Login operatorId) {
+ this.orderId = orderId;
+ this.orderName = orderName;
+ this.orderPhone = orderPhone;
+ this.orderIDcard = orderIDcard;
+ this.typeId = typeId;
+ this.arrireDate = arrireDate;
+ this.leaveDate = leaveDate;
+ this.orderState = orderState;
+ this.checkNum = checkNum;
+ this.roomId = roomId;
+ this.price = price;
+ this.checkPrice = checkPrice;
+ this.discount = discount;
+ this.discountReason = discountReason;
+ this.addBed = addBed;
+ this.addBedPrice = addBedPrice;
+ this.orderMoney = orderMoney;
+ this.remark = remark;
+ this.operatorId = operatorId;
+ }
+
+ public String getOrderId() {
+ return orderId;
+ }
+
+ public void setOrderId(String orderId) {
+ this.orderId = orderId;
+ }
+
+ public String getOrderName() {
+ return orderName;
+ }
+
+ public void setOrderName(String orderName) {
+ this.orderName = orderName;
+ }
+
+ public String getOrderPhone() {
+ return orderPhone;
+ }
+
+ public void setOrderPhone(String orderPhone) {
+ this.orderPhone = orderPhone;
+ }
+
+ public String getOrderIDcard() {
+ return orderIDcard;
+ }
+
+ public void setOrderIDcard(String orderIDcard) {
+ this.orderIDcard = orderIDcard;
+ }
+
+ public RoomType getTypeId() {
+ return typeId;
+ }
+
+ public void setTypeId(RoomType typeId) {
+ this.typeId = typeId;
+ }
+
+ public String getArrireDate() {
+ return arrireDate;
+ }
+
+ public void setArrireDate(String arrireDate) {
+ this.arrireDate = arrireDate;
+ }
+
+ public String getLeaveDate() {
+ return leaveDate;
+ }
+
+ public void setLeaveDate(String leaveDate) {
+ this.leaveDate = leaveDate;
+ }
+
+ public String getOrderState() {
+ return orderState;
+ }
+
+ public void setOrderState(String orderState) {
+ this.orderState = orderState;
+ }
+
+ public String getCheckNum() {
+ return checkNum;
+ }
+
+ public void setCheckNum(String checkNum) {
+ this.checkNum = checkNum;
+ }
+
+ public String getRoomId() {
+ return roomId;
+ }
+
+ public void setRoomId(String roomId) {
+ this.roomId = roomId;
+ }
+
+ public String getPrice() {
+ return price;
+ }
+
+ public void setPrice(String price) {
+ this.price = price;
+ }
+
+ public String getCheckPrice() {
+ return checkPrice;
+ }
+
+ public void setCheckPrice(String checkPrice) {
+ this.checkPrice = checkPrice;
+ }
+
+ public int getDiscount() {
+ return discount;
+ }
+
+ public void setDiscount(int discount) {
+ this.discount = discount;
+ }
+
+ public String getDiscountReason() {
+ return discountReason;
+ }
+
+ public void setDiscountReason(String discountReason) {
+ this.discountReason = discountReason;
+ }
+
+ public String getAddBed() {
+ return addBed;
+ }
+
+ public void setAddBed(String addBed) {
+ this.addBed = addBed;
+ }
+
+ public String getAddBedPrice() {
+ return addBedPrice;
+ }
+
+ public void setAddBedPrice(String addBedPrice) {
+ this.addBedPrice = addBedPrice;
+ }
+
+ public String getOrderMoney() {
+ return orderMoney;
+ }
+
+ public void setOrderMoney(String orderMoney) {
+ this.orderMoney = orderMoney;
+ }
+
+ public String getRemark() {
+ return remark;
+ }
+
+ public void setRemark(String remark) {
+ this.remark = remark;
+ }
+
+ public Login getOperatorId() {
+ return operatorId;
+ }
+
+ public void setOperatorId(Login operatorId) {
+ this.operatorId = operatorId;
+ }
+
+ public boolean isNull() {
+ return isNull;
+ }
+
+ public void setNull(boolean aNull) {
+ isNull = aNull;
+ }
+
+ @Override
+ public String toString() {
+ return "OrderInfo{" +
+ "orderId='" + orderId + '\'' +
+ ", orderName='" + orderName + '\'' +
+ ", orderPhone='" + orderPhone + '\'' +
+ ", orderIDcard='" + orderIDcard + '\'' +
+ ", typeId=" + typeId +
+ ", arrireDate='" + arrireDate + '\'' +
+ ", leaveDate='" + leaveDate + '\'' +
+ ", orderState='" + orderState + '\'' +
+ ", checkNum='" + checkNum + '\'' +
+ ", roomId='" + roomId + '\'' +
+ ", price='" + price + '\'' +
+ ", checkPrice='" + checkPrice + '\'' +
+ ", discount=" + discount +
+ ", discountReason='" + discountReason + '\'' +
+ ", addBed='" + addBed + '\'' +
+ ", addBedPrice='" + addBedPrice + '\'' +
+ ", orderMoney='" + orderMoney + '\'' +
+ ", remark='" + remark + '\'' +
+ ", operatorId=" + operatorId +
+ ", isNull=" + isNull +
+ '}';
+ }
+}
diff --git a/src/main/java/com/inks/hb/orderinfo/pojo/OrderToTable.java b/src/main/java/com/inks/hb/orderinfo/pojo/OrderToTable.java
new file mode 100644
index 0000000..407e65e
--- /dev/null
+++ b/src/main/java/com/inks/hb/orderinfo/pojo/OrderToTable.java
@@ -0,0 +1,163 @@
+package com.inks.hb.orderinfo.pojo;
+
+/**
+ * 怎么的呢
+ * 这个类将关联类换成了String
+ * 并且去掉了前端不需要的字段
+ * 都怪数据库设计时不仔细呀
+ */
+public class OrderToTable {
+
+ private String orderId; //预订单号->直接获取时间戳?存进去 1
+
+ private String orderName; //预定人 2
+
+ private String orderPhone; //联系电话 3
+
+ private String orderIDcard; // 4
+
+ private String arrireDate; //抵店时间 5
+
+ private String leaveDate; //离店时间 6
+
+ private String typeId; //房间类型->对应roomtype表 7<-------------------
+
+ private String checkNum; //入住人数 8
+
+ private String price; //客房价格 9
+
+ private String checkPrice; //入住价格 10
+
+ private int discount; //折扣 11<-------------------
+
+ private String discountReason; //折扣原因 12
+
+ private String addBed; //是否加床 13
+
+ private String addBedPrice; //加床价格 14
+
+ private String orderMoney; //预收款 15
+
+ private String orderState; //单据状态->该字段前端做下拉框写死 16
+
+ private String remark; //备注 17
+
+ private String operatorId; //操作员->登录 19<-------------------
+
+ public OrderToTable(String orderId, String orderName, String orderPhone, String orderIDcard, String arrireDate, String leaveDate, String typeId, String checkNum, String price, String checkPrice, int discount, String discountReason, String addBed, String addBedPrice, String orderMoney, String orderState, String remark, String operatorId) {
+ this.orderId = orderId;
+ this.orderName = orderName;
+ this.orderPhone = orderPhone;
+ this.orderIDcard = orderIDcard;
+ this.arrireDate = arrireDate;
+ this.leaveDate = leaveDate;
+ this.typeId = typeId;
+ this.checkNum = checkNum;
+ this.price = price;
+ this.checkPrice = checkPrice;
+ this.discount = discount;
+ this.discountReason = discountReason;
+ this.addBed = addBed;
+ this.addBedPrice = addBedPrice;
+ this.orderMoney = orderMoney;
+ this.orderState = orderState;
+ this.remark = remark;
+ this.operatorId = operatorId;
+ }
+
+ public String getOrderId() {
+ return orderId;
+ }
+
+ public String getOrderName() {
+ return orderName;
+ }
+
+ public String getOrderPhone() {
+ return orderPhone;
+ }
+
+ public String getOrderIDcard() {
+ return orderIDcard;
+ }
+
+ public String getArrireDate() {
+ return arrireDate;
+ }
+
+ public String getLeaveDate() {
+ return leaveDate;
+ }
+
+ public String getTypeId() {
+ return typeId;
+ }
+
+ public String getCheckNum() {
+ return checkNum;
+ }
+
+ public String getPrice() {
+ return price;
+ }
+
+ public String getCheckPrice() {
+ return checkPrice;
+ }
+
+ public int getDiscount() {
+ return discount;
+ }
+
+ public String getDiscountReason() {
+ return discountReason;
+ }
+
+ public String getAddBed() {
+ return addBed;
+ }
+
+ public String getAddBedPrice() {
+ return addBedPrice;
+ }
+
+ public String getOrderMoney() {
+ return orderMoney;
+ }
+
+ public String getOrderState() {
+ return orderState;
+ }
+
+ public String getRemark() {
+ return remark;
+ }
+
+ public String getOperatorId() {
+ return operatorId;
+ }
+
+ @Override
+ public String toString() {
+ return "OrderToTable{" +
+ "orderId='" + orderId + '\'' +
+ ", orderName='" + orderName + '\'' +
+ ", orderPhone='" + orderPhone + '\'' +
+ ", orderIDcard='" + orderIDcard + '\'' +
+ ", arrireDate='" + arrireDate + '\'' +
+ ", leaveDate='" + leaveDate + '\'' +
+ ", typeId='" + typeId + '\'' +
+ ", checkNum='" + checkNum + '\'' +
+ ", price='" + price + '\'' +
+ ", checkPrice='" + checkPrice + '\'' +
+ ", discount=" + discount +
+ ", discountReason='" + discountReason + '\'' +
+ ", addBed='" + addBed + '\'' +
+ ", addBedPrice='" + addBedPrice + '\'' +
+ ", orderMoney='" + orderMoney + '\'' +
+ ", orderState='" + orderState + '\'' +
+ ", remark='" + remark + '\'' +
+ ", operatorId='" + operatorId + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/com/inks/hb/orderinfo/service/OrderInfoService.java b/src/main/java/com/inks/hb/orderinfo/service/OrderInfoService.java
new file mode 100644
index 0000000..c994213
--- /dev/null
+++ b/src/main/java/com/inks/hb/orderinfo/service/OrderInfoService.java
@@ -0,0 +1,43 @@
+package com.inks.hb.orderinfo.service;
+
+import com.inks.hb.orderinfo.pojo.OrderInfo;
+
+import java.util.ArrayList;
+
+public interface OrderInfoService {
+
+ /**
+ * 插入一条数据
+ *
+ * @param orderInfo 预订单
+ * @return -1失败 0重名 1成功
+ */
+ int insertOrderInfo(OrderInfo orderInfo);
+
+ //删除
+ int deleteOrderInfo(String orderId);
+
+ //更新
+ int updateOrderInfo(OrderInfo orderInfo);
+
+ //查询单条
+ OrderInfo query(String orderId);
+
+ //查询多条
+ ArrayList query(int page, int limit);
+
+ //查询长度
+ int queryOrderInfoNum();
+
+ //俩查询 1:查名称 2:查类型
+ ArrayList queryOrder(int make, String select);
+
+ /**
+ * 查重函数
+ *
+ * @param newName oldName 房间类型名称
+ * @return 0:已经存在 1:未存在 2:与自身相同
+ */
+ int queryRepeat(String newName, String oldName);
+}
+
diff --git a/src/main/java/com/inks/hb/orderinfo/service/OrderInfoServiceImpl.java b/src/main/java/com/inks/hb/orderinfo/service/OrderInfoServiceImpl.java
new file mode 100644
index 0000000..fc8192d
--- /dev/null
+++ b/src/main/java/com/inks/hb/orderinfo/service/OrderInfoServiceImpl.java
@@ -0,0 +1,134 @@
+package com.inks.hb.orderinfo.service;
+
+import com.inks.hb.orderinfo.dao.OrderInfoDao;
+import com.inks.hb.orderinfo.pojo.OrderInfo;
+import com.inks.hb.roomtype.dao.RoomTypeDao;
+import com.inks.hb.roomtype.pojo.RoomType;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+public class OrderInfoServiceImpl implements OrderInfoService {
+
+ private OrderInfoDao dao = new OrderInfoDao();
+
+ @Override
+ public int insertOrderInfo(OrderInfo orderInfo) {
+
+ try {
+ String orderId = orderInfo.getOrderId();
+ if (queryRepeat(orderId, orderId) != 1)
+ return 0;
+ dao.insertData(orderInfo);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return -1;
+ }
+ return 1;
+ }
+
+ @Override
+ public int deleteOrderInfo(String orderId) {
+ OrderInfo orderInfo = new OrderInfo();
+ orderInfo.setOrderId(orderId);
+
+ try {
+ dao.deleteData(orderInfo);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return -1;
+ }
+ return 1;
+ }
+
+ @Override
+ public int updateOrderInfo(OrderInfo orderInfo) {
+ try {
+ dao.updateData(orderInfo);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ e.printStackTrace();
+ return -1;
+ }
+ return 1;
+ }
+
+ @Override
+ public OrderInfo query(String orderId) {
+ OrderInfo orderInfo = new OrderInfo();
+ orderInfo.setOrderId(orderId);
+
+ try {
+ return (OrderInfo) dao.query(orderInfo);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return null;
+ }
+ }
+
+ @Override
+ public ArrayList query(int page, int limit) {
+ int start = (page * limit) - limit + 1; //每一页的起始位置
+
+ if (start < 1) //小于1的话会触发一个错误
+ start = 1; //但是理论上page和limit是由table表格生成的参数
+
+ try {
+ return dao.query(start, limit);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return null;
+ }
+ }
+
+ @Override
+ public int queryOrderInfoNum() {
+ try {
+ return dao.queryDataNum();
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return -1;
+ }
+ }
+
+ @Override
+ public ArrayList queryOrder(int make, String select) {
+
+ if (make == 2) { //2:查类型
+ try {
+ // 然而这样写失去了对类型的模糊查询
+ RoomType roomType = new RoomTypeDao().queryName(select);
+ select = roomType.getTypeId();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ try {
+ return dao.queryOrder(make, select);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return null;
+ }
+ }
+
+ @Override
+ public int queryRepeat(String newName, String oldName) {
+ OrderInfo orderInfoQuery = new OrderInfo();
+ orderInfoQuery.setOrderId(newName);
+ OrderInfo orderInfo;
+ try {
+ orderInfo = (OrderInfo) dao.query(orderInfoQuery);
+ if (!orderInfo.isNull()) {
+ if (orderInfo.getOrderId().equals(oldName))
+ return 2; //和旧名称重复
+ return 0; //重复
+ } else
+ return 1; //不重复
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return -1; //异常
+ }
+ }
+
+}
diff --git a/src/main/java/com/inks/hb/roomtype/controller/InsertRoomTypeServlet.java b/src/main/java/com/inks/hb/roomtype/controller/InsertRoomTypeServlet.java
new file mode 100644
index 0000000..abc6b29
--- /dev/null
+++ b/src/main/java/com/inks/hb/roomtype/controller/InsertRoomTypeServlet.java
@@ -0,0 +1,51 @@
+package com.inks.hb.roomtype.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.roomtype.pojo.RoomType;
+import com.inks.hb.roomtype.service.RoomTypeService;
+import com.inks.hb.roomtype.service.RoomTypeServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+@WebServlet(name = "InsertRoomTypeServlet", value = "/InsertRoomTypeServlet")
+public class InsertRoomTypeServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("application/json; charset=utf-8");
+
+ // 获取前端传递的json数据
+ BufferedReader reader = request.getReader();
+ String json = reader.readLine();
+
+ // 解析json
+ Gson gson = new Gson();
+ RoomType roomType = gson.fromJson(json, RoomType.class);
+
+ //主键ID没有想好暂时就用时间吧
+ Date day = new Date();
+ SimpleDateFormat df = new SimpleDateFormat("yyMMddHHmmss");
+ roomType.setTypeId("RT" + df.format(day));
+
+ // 调用service
+ RoomTypeService service = new RoomTypeServiceImpl();
+ PrintWriter out = response.getWriter();
+
+ int code = service.insertRoomType(roomType);
+
+ //code 1:插入成功 0:存在同名项 -1:插入失败
+ out.print(gson.toJson(code));
+ }
+}
diff --git a/src/main/java/com/inks/hb/roomtype/controller/QueryRoomTypeNameServlet.java b/src/main/java/com/inks/hb/roomtype/controller/QueryRoomTypeNameServlet.java
new file mode 100644
index 0000000..3bba358
--- /dev/null
+++ b/src/main/java/com/inks/hb/roomtype/controller/QueryRoomTypeNameServlet.java
@@ -0,0 +1,36 @@
+package com.inks.hb.roomtype.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.roomtype.service.RoomTypeService;
+import com.inks.hb.roomtype.service.RoomTypeServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+@WebServlet(name = "QueryRoomTypeNameServlet", value = "/QueryRoomTypeNameServlet")
+public class QueryRoomTypeNameServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ PrintWriter out = response.getWriter();
+
+ // 调用service
+ RoomTypeService service = new RoomTypeServiceImpl();
+
+ String newName = request.getParameter("new"); //获得姓名
+ String oldName = request.getParameter("old");
+
+ // 转换为json字符串格式
+ Gson gson = new Gson();
+ out.print(gson.toJson(service.queryRepeat(newName, oldName)));
+ }
+}
diff --git a/src/main/java/com/inks/hb/roomtype/controller/RoomInfoExcelServlet.java b/src/main/java/com/inks/hb/roomtype/controller/RoomInfoExcelServlet.java
new file mode 100644
index 0000000..dd58a9c
--- /dev/null
+++ b/src/main/java/com/inks/hb/roomtype/controller/RoomInfoExcelServlet.java
@@ -0,0 +1,34 @@
+package com.inks.hb.roomtype.controller;
+
+import com.inks.hb.common.ExportExcel;
+import com.inks.hb.roomtype.pojo.RoomType;
+import com.inks.hb.roomtype.service.RoomTypeService;
+import com.inks.hb.roomtype.service.RoomTypeServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+
+@WebServlet(name = "RoomInfoExcelServlet", value = "/RoomInfoExcelServlet")
+public class RoomInfoExcelServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
+
+ RoomTypeService service = new RoomTypeServiceImpl();
+
+ ArrayList infoArrayList = null;
+
+ infoArrayList = service.query(1, service.queryRoomTypeNum());
+
+ String[] headers = {"类型编号", "类型名称", "价格", "拼房价格", "可超预定数", "是否可拼房"};
+ String fileName = "房间类型信息";
+
+ ExportExcel ee = new ExportExcel<>();
+ ee.exportExcel(headers, infoArrayList, fileName, response);
+ }
+}
diff --git a/src/main/java/com/inks/hb/roomtype/controller/RoomTypeServlet.java b/src/main/java/com/inks/hb/roomtype/controller/RoomTypeServlet.java
new file mode 100644
index 0000000..c39db07
--- /dev/null
+++ b/src/main/java/com/inks/hb/roomtype/controller/RoomTypeServlet.java
@@ -0,0 +1,121 @@
+package com.inks.hb.roomtype.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.common.PojotoGson;
+import com.inks.hb.roomtype.pojo.RoomType;
+import com.inks.hb.roomtype.service.RoomTypeService;
+import com.inks.hb.roomtype.service.RoomTypeServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+
+/**
+ * 与表格相关的全部操作
+ * 状态标志: make 0重载 1新增 2修改 3搜索 4删除
+ */
+@WebServlet(name = "RoomTypeServlet", value = "/RoomTypeServlet")
+public class RoomTypeServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+ PrintWriter out = response.getWriter();
+
+ int page = Integer.parseInt(request.getParameter("page")); // 当前页码
+ int limit = Integer.parseInt(request.getParameter("limit")); // 每页的数据量
+ int make = Integer.parseInt(request.getParameter("make")); //状态标志
+
+ // 调用service
+ RoomTypeService service = new RoomTypeServiceImpl();
+
+ // 默认输出信息
+ String code = "0"; //状态码
+ String msg = "数据查询正常"; //状态信息
+ String count = ""; //数据总数
+ ArrayList list = new ArrayList<>(); //数据内容
+ ArrayList searchList = new ArrayList<>(); //数据内容
+
+ //单个全局属性
+ String typeId = ""; //类型编号
+ String typeName = ""; //类型名称
+ String price; //价格
+ String splicPrice; //拼房价格
+ int exceedance; //可超预定数
+ String isSplice; //是否可拼房
+ RoomType roomType = null;
+
+ //获取对应状态属性
+ if (make == 1 || make == 2) { //1和2这部分完全是相同的
+ typeId = request.getParameter("typeId");
+ typeName = request.getParameter("typeName");
+ price = request.getParameter("price");
+ splicPrice = request.getParameter("splicPrice");
+ exceedance = Integer.parseInt(request.getParameter("exceedance"));
+ isSplice = request.getParameter("isSplice");
+ roomType = new RoomType(typeId, typeName, price, splicPrice, exceedance, isSplice);
+ } else if (make == 4) {
+ typeId = request.getParameter("typeId");
+ } else if (make == 3) {
+ typeName = request.getParameter("typeName");
+ }
+
+ // 状态标志 make 0重载 1新增 2修改 3搜索 4删除
+ switch (make) {
+ case 1:
+ if (service.insertRoomType(roomType) == -1) {
+ msg = "插入异常";
+ code = "-1";
+ }
+ break;
+ case 2:
+ if (service.updateRoomType(roomType) == -1) {
+ msg = "修改异常";
+ code = "-1";
+ }
+ break;
+ case 3:
+ list = service.query(1, service.queryRoomTypeNum());
+ searchList.clear();
+ for (Object temp : list) {
+ roomType = (RoomType) temp; //用contains模糊查询 机智啊,这样连mysql的like语句都不用写 --2017.12.7 改
+ if (roomType.getTypeName().contains(typeName)) {
+ searchList.add(roomType);
+ }
+ }
+ break;
+ case 4:
+ if (service.deleteRoomType(typeId) == -1) {
+ msg = "删除失败";
+ code = "-1";
+ }
+ break;
+ }
+
+ if (make != 3) {
+ list = service.query(page, limit);
+ count = String.valueOf(service.queryRoomTypeNum());
+ } else { //这部分算是对3搜索的特殊处理,放这儿和放case里一样的。
+ int size = searchList.size();
+ if (size == 0) {
+ msg = "查无此项";
+ code = "-1";
+ } else {
+ list = searchList;
+ count = Integer.toString(size);
+ }
+ }
+
+ PojotoGson pojotoGson = new PojotoGson(code, msg, count, list);
+ Gson gson = new Gson();
+ out.print(gson.toJson(pojotoGson));
+ }
+}
diff --git a/src/main/java/com/inks/hb/roomtype/controller/selectRomeTypeIdServlet.java b/src/main/java/com/inks/hb/roomtype/controller/selectRomeTypeIdServlet.java
new file mode 100644
index 0000000..b2ada08
--- /dev/null
+++ b/src/main/java/com/inks/hb/roomtype/controller/selectRomeTypeIdServlet.java
@@ -0,0 +1,40 @@
+package com.inks.hb.roomtype.controller;
+
+import com.google.gson.Gson;
+import com.inks.hb.roomtype.service.RoomTypeService;
+import com.inks.hb.roomtype.service.RoomTypeServiceImpl;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+
+@WebServlet(name = "selectRomeTypeIdServlet", value = "/selectRomeTypeIdServlet")
+public class selectRomeTypeIdServlet extends HttpServlet {
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ this.doGet(request, response);
+ }
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ // 设置编码
+ request.setCharacterEncoding("utf-8");
+ response.setContentType("text/html;charset=utf-8");
+
+ // 响应输出流
+ PrintWriter out = response.getWriter();
+
+ RoomTypeService service = new RoomTypeServiceImpl();
+
+
+ ArrayList list = service.query(1, service.queryRoomTypeNum());
+ //转换为json字符串格式
+ Gson gson = new Gson();
+ out.print(gson.toJson(list));
+
+ }
+}
diff --git a/src/main/java/com/inks/hb/roomtype/dao/RoomTypeDao.java b/src/main/java/com/inks/hb/roomtype/dao/RoomTypeDao.java
new file mode 100644
index 0000000..2e33de0
--- /dev/null
+++ b/src/main/java/com/inks/hb/roomtype/dao/RoomTypeDao.java
@@ -0,0 +1,179 @@
+package com.inks.hb.roomtype.dao;
+
+import com.inks.hb.common.CommonDao;
+import com.inks.hb.common.DBUtil;
+import com.inks.hb.roomtype.pojo.RoomType;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+/**
+ * 房间类型 DAO
+ * 提供独立函数:public RoomType queryName(String typeName) throws SQLException
+ * 根据类型名称进行查询
+ */
+public class RoomTypeDao implements CommonDao {
+
+ @Override
+ public void insertData(Object o) throws SQLException {
+
+ RoomType roomType = (RoomType) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "INSERT INTO roomType VALUES (?,?,?,?,?,?)";
+
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, roomType.getTypeId());
+ pstmt.setString(2, roomType.getTypeName());
+ pstmt.setString(3, roomType.getPrice());
+ pstmt.setString(4, roomType.getSplicPrice());
+ pstmt.setInt(5, roomType.getExceedance());
+ pstmt.setString(6, roomType.getIsSplice());
+
+ pstmt.executeUpdate();
+
+ pstmt.close();
+ }
+
+ @Override
+ public void deleteData(Object o) throws SQLException {
+ RoomType roomType = (RoomType) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "DELETE FROM roomType WHERE typeId = ?";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, roomType.getTypeId());
+
+ pstmt.executeUpdate();
+ pstmt.close();
+ }
+
+ @Override
+ public void updateData(Object o) throws SQLException {
+ RoomType roomType = (RoomType) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "UPDATE roomType SET typeName = ? ,price = ? ,splicPrice = ? ,exceedance = ? ,isSplice = ? WHERE typeId = ?";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, roomType.getTypeName());
+ pstmt.setString(2, roomType.getPrice());
+ pstmt.setString(3, roomType.getSplicPrice());
+ pstmt.setInt(4, roomType.getExceedance());
+ pstmt.setString(5, roomType.getIsSplice());
+ pstmt.setString(6, roomType.getTypeId());
+
+ pstmt.executeUpdate();
+ pstmt.close();
+ }
+
+ @Override
+ public int queryDataNum() throws SQLException {
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "select count(*) from roomType;";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ ResultSet rs = pstmt.executeQuery();
+
+ int num;
+ if (rs.next()) num = rs.getInt("count(*)");
+ else num = 0;
+
+ rs.close();
+ pstmt.close();
+
+ return num;
+ }
+
+ @Override
+ public ArrayList query(int start, int length) throws SQLException {
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "select * from roomType limit ?, ?;";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setInt(1, start - 1); //减一,详见声明部分
+ pstmt.setInt(2, length);
+ ResultSet rs = pstmt.executeQuery();
+
+ ArrayList list = new ArrayList<>();
+ RoomType roomType;
+
+ while (rs.next()) {
+ roomType = new RoomType(rs.getString(1), rs.getString(2), rs.getString(3)
+ , rs.getString(4), rs.getInt(5), rs.getString(6));
+ list.add(roomType);
+ }
+
+ rs.close();
+ pstmt.close();
+
+ return list;
+ }
+
+ @Override
+ public Object query(Object o) throws SQLException {
+ RoomType roomTypeQuery = (RoomType) o;
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "SELECT * FROM roomType WHERE typeId = ?";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, roomTypeQuery.getTypeId());
+ ResultSet rs = pstmt.executeQuery();
+
+ RoomType roomType = null;
+ while (rs.next()) {
+ roomType = new RoomType(rs.getString(1), rs.getString(2), rs.getString(3)
+ , rs.getString(4), rs.getInt(5), rs.getString(6));
+ }
+
+ if (roomType == null) {
+ roomType = new RoomType();
+ roomType.setNull(true);
+ }
+ rs.close();
+ pstmt.close();
+
+ return roomType;
+ }
+
+ /**
+ * 根据类型名称进行查询
+ *
+ * @param typeName 包装成typeName的待查询对象
+ * @return 包装成roomType的查询结果
+ * @throws SQLException 数据库
+ */
+ public RoomType queryName(String typeName) throws SQLException {
+
+ Connection conn = DBUtil.getConnection();
+
+ String sql = "SELECT * FROM roomType WHERE typeName = ?";
+ PreparedStatement pstmt = conn.prepareStatement(sql);
+ pstmt.setString(1, typeName);
+ ResultSet rs = pstmt.executeQuery();
+
+ RoomType roomTypeQuery = null;
+ while (rs.next()) {
+ roomTypeQuery = new RoomType(rs.getString(1), rs.getString(2), rs.getString(3)
+ , rs.getString(4), rs.getInt(5), rs.getString(6));
+ }
+
+ if (roomTypeQuery == null) {
+ roomTypeQuery = new RoomType();
+ roomTypeQuery.setNull(true);
+ }
+
+ rs.close();
+ pstmt.close();
+
+ return roomTypeQuery;
+ }
+}
diff --git a/src/main/java/com/inks/hb/roomtype/pojo/RoomType.java b/src/main/java/com/inks/hb/roomtype/pojo/RoomType.java
new file mode 100644
index 0000000..eaf5841
--- /dev/null
+++ b/src/main/java/com/inks/hb/roomtype/pojo/RoomType.java
@@ -0,0 +1,121 @@
+package com.inks.hb.roomtype.pojo;
+
+/**
+ * 2017.11.23 --------
+ * 添加isNull字段,现在可以通过setNull设置元素信息,通过isNull读取信息
+ * 原构造函数不变,不提供含该字段的构造函数,该字段应主要用于查询函数(查询函数不返回未实例化的对象)
+ * ------------
+ */
+public class RoomType {
+
+ private String typeId; //类型编号
+
+ private String typeName; //类型名称
+
+ private String price; //价格
+
+ private String splicPrice; //拼房价格
+
+ private int exceedance; //可超预定数
+
+ private String isSplice; //是否可拼房
+
+ private boolean isNull; //是否为空值对象
+
+ public RoomType() {
+ super();
+ }
+
+ public RoomType(String typeId) {
+ this.typeId = typeId;
+ }
+
+ public RoomType(String typeId, String typeName, boolean isNull) {
+ this.typeId = typeId;
+ this.typeName = typeName;
+ this.isNull = isNull;
+ }
+
+ public RoomType(String typeId, String typeName, String price, String splicPrice, int exceedance, String isSplice) {
+ this.typeId = typeId;
+ this.typeName = typeName;
+ this.price = price;
+ this.splicPrice = splicPrice;
+ this.exceedance = exceedance;
+ this.isSplice = isSplice;
+ }
+
+ public String getTypeId() {
+ return typeId;
+ }
+
+ public void setTypeId(String typeId) {
+ this.typeId = typeId;
+ }
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+ public String getPrice() {
+ return price;
+ }
+
+ public void setPrice(String price) {
+ this.price = price;
+ }
+
+ public String getSplicPrice() {
+ return splicPrice;
+ }
+
+ public void setSplicPrice(String splicPrice) {
+ this.splicPrice = splicPrice;
+ }
+
+ public int getExceedance() {
+ return exceedance;
+ }
+
+ public void setExceedance(int exceedance) {
+ this.exceedance = exceedance;
+ }
+
+ public String getIsSplice() {
+ return isSplice;
+ }
+
+ public void setIsSplice(String isSplice) {
+ this.isSplice = isSplice;
+ }
+
+ public boolean isNull() {
+ return isNull;
+ }
+
+ /**
+ * 如果为null,则设置为true,否则false
+ *
+ * @param aNull 对象是否为空
+ */
+ public void setNull(boolean aNull) {
+ isNull = aNull;
+ }
+
+ @Override
+ public String toString() {
+ return "RoomType{" +
+ "typeId='" + typeId + '\'' +
+ ", typeName='" + typeName + '\'' +
+ ", price='" + price + '\'' +
+ ", splicPrice='" + splicPrice + '\'' +
+ ", exceedance=" + exceedance +
+ ", isSplice='" + isSplice + '\'' +
+ ", isNull=" + isNull +
+ '}';
+ }
+}
diff --git a/src/main/java/com/inks/hb/roomtype/service/RoomTypeService.java b/src/main/java/com/inks/hb/roomtype/service/RoomTypeService.java
new file mode 100644
index 0000000..b718ee8
--- /dev/null
+++ b/src/main/java/com/inks/hb/roomtype/service/RoomTypeService.java
@@ -0,0 +1,38 @@
+package com.inks.hb.roomtype.service;
+
+import com.inks.hb.roomtype.pojo.RoomType;
+
+import java.util.ArrayList;
+
+/**
+ * 数据异常在本层解决
+ * 但凡出现SQL方面异常均返回-1
+ */
+public interface RoomTypeService {
+
+ //增添
+ int insertRoomType(RoomType roomType);
+
+ //删除
+ int deleteRoomType(String typeId);
+
+ //更新
+ int updateRoomType(RoomType roomType);
+
+ //查询单条
+ RoomType query(String typeId);
+
+ //查询多条
+ ArrayList query(int page, int limit);
+
+ //查询长度
+ int queryRoomTypeNum();
+
+ /**
+ * 查重函数
+ *
+ * @param newName oldName 房间类型名称
+ * @return 0:已经存在 1:未存在 2:与自身相同
+ */
+ int queryRepeat(String newName, String oldName);
+}
diff --git a/src/main/java/com/inks/hb/roomtype/service/RoomTypeServiceImpl.java b/src/main/java/com/inks/hb/roomtype/service/RoomTypeServiceImpl.java
new file mode 100644
index 0000000..65a7191
--- /dev/null
+++ b/src/main/java/com/inks/hb/roomtype/service/RoomTypeServiceImpl.java
@@ -0,0 +1,114 @@
+package com.inks.hb.roomtype.service;
+
+import com.inks.hb.roomtype.dao.RoomTypeDao;
+import com.inks.hb.roomtype.pojo.RoomType;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+/**
+ * 修订:2017.11.23
+ * 将异常放在了本层处理
+ * 如果出现数据库相关异常,则返回-1或者null
+ */
+public class RoomTypeServiceImpl implements RoomTypeService {
+
+ private RoomTypeDao dao = new RoomTypeDao();
+
+ @Override
+ public int insertRoomType(RoomType roomType) {
+ try {
+ String name = roomType.getTypeName();
+ if (queryRepeat(name, name) != 1)
+ return 0;
+ dao.insertData(roomType);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return -1;
+ }
+ return 1;
+ }
+
+ @Override
+ public int deleteRoomType(String typeId) {
+ RoomType roomType = new RoomType();
+ roomType.setTypeId(typeId);
+
+ try {
+ dao.deleteData(roomType);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return -1;
+ }
+ return 1;
+ }
+
+ @Override
+ public int updateRoomType(RoomType roomType) {
+ try {
+ dao.updateData(roomType);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return -1;
+ }
+ return 1;
+ }
+
+ @Override
+ public RoomType query(String typeId) {
+ RoomType roomType = new RoomType();
+ roomType.setTypeId(typeId);
+
+ try {
+ return (RoomType) dao.query(roomType);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return null;
+ }
+ }
+
+ @Override
+ public ArrayList query(int page, int limit) {
+ int start = (page * limit) - limit + 1; //每一页的起始位置
+
+ if (start < 1) //小于1的话会触发一个错误
+ start = 1; //但是理论上page和limit是由table表格生成的参数
+
+ try {
+ return dao.query(start, limit);
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return null;
+ }
+ }
+
+ @Override
+ public int queryRoomTypeNum() {
+
+ try {
+ return dao.queryDataNum();
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return -1;
+ }
+ }
+
+ @Override
+ public int queryRepeat(String newName, String oldName) {
+ RoomType roomType;
+
+ try {
+ roomType = dao.queryName(newName);
+ if (!roomType.isNull()) {//表示存在同名项
+ if (roomType.getTypeName().equals(oldName))
+ return 2; //表示存在同名项,但是是与传递来的相同
+ return 0;
+ } else
+ return 1;
+ } catch (SQLException e) {
+ System.out.println(e.getErrorCode() + e.getMessage());
+ return -1;
+ }
+ }
+
+}
diff --git a/src/main/main.iml b/src/main/main.iml
new file mode 100644
index 0000000..e44df5c
--- /dev/null
+++ b/src/main/main.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/c3p0-config.xml b/src/main/resources/c3p0-config.xml
new file mode 100644
index 0000000..b2bbf8e
--- /dev/null
+++ b/src/main/resources/c3p0-config.xml
@@ -0,0 +1,23 @@
+
+
+
+
+ jdbc:mysql://localhost:3306/hotelbook?characterEncoding=utf8&useSSL=true
+
+ com.mysql.jdbc.Driver
+
+ root
+
+ 1q2w3e4r
+
+ 3
+
+ 10
+
+ 2
+
+ 10
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/rebel.xml b/src/main/resources/rebel.xml
new file mode 100644
index 0000000..58a42e0
--- /dev/null
+++ b/src/main/resources/rebel.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/sql/Hotelbook ER diagram.pdf b/src/sql/Hotelbook ER diagram.pdf
new file mode 100644
index 0000000..fd417bc
Binary files /dev/null and b/src/sql/Hotelbook ER diagram.pdf differ
diff --git a/src/sql/sql.sql b/src/sql/sql.sql
new file mode 100644
index 0000000..ee884eb
--- /dev/null
+++ b/src/sql/sql.sql
@@ -0,0 +1,170 @@
+-- 建立hotelbook数据库
+CREATE SCHEMA `hotelbook` DEFAULT CHARACTER SET utf8 ;
+
+-- 建立登录表
+CREATE TABLE `hotelbook`.`login` (
+ `loginId` INT NOT NULL AUTO_INCREMENT COMMENT '登录内部标示,主键、自动增长。',
+ `loginName` VARCHAR(45) NOT NULL COMMENT '登录用户名,前台唯一性的标识。不能重复。',
+ `loginPwd` VARCHAR(45) NOT NULL COMMENT '登录用户的密码,不能为空。',
+ `loginNickName` VARCHAR(45) NULL COMMENT '登录用户的昵称' ,
+ `loginAdmin` INT NULL COMMENT '权限,默认最高权限是0',
+ PRIMARY KEY (`loginId`),
+ UNIQUE INDEX `loginName_UNIQUE` (`loginName` ASC));
+
+-- 为login表插入默认的管理员用户
+INSERT INTO `hotelbook`.`login` (`loginName`,`loginPwd`,`loginNickName`,`loginAdmin`) VALUE ("root","bUg4eWhCTC1uKmotMmdtQ3Rvb3I=","管理员",0);
+
+-- 建立日志表
+CREATE TABLE `hotelbook`.`logInfo` (
+ `logId` INT NOT NULL AUTO_INCREMENT COMMENT '日志,主键、自动增长。',
+ `logName` VARCHAR(45) NOT NULL COMMENT '日志项目',
+ `loginId` INT NOT NULL COMMENT '用户 外键 login表字段值',
+ `loginName` VARCHAR(45) NULL COMMENT '用户名称',
+ `logDate` VARCHAR(45) NULL COMMENT '日志时间' ,
+ PRIMARY KEY (`logId`),
+ CONSTRAINT `fk_logInfo_1`
+ FOREIGN KEY (`loginId`)
+ REFERENCES `hotelbook`.`login` (`loginId`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION);
+
+-- 创建主体数据表
+-- 核心数据库内容
+-- 将不使用存储过程,仅仅用到外键/外联
+-- 数据维护主要依靠后端维护
+
+-- 楼层信息
+CREATE TABLE `hotelbook`.`floorInfo` (
+ `floorId` INT NOT NULL AUTO_INCREMENT COMMENT '楼层编号',
+ `floorName` VARCHAR(45) NULL COMMENT '楼层名称',
+ PRIMARY KEY (`floorId`));
+
+-- 客房类型
+CREATE TABLE `hotelbook`.`roomType` (
+ `typeId` VARCHAR(45) NOT NULL COMMENT '类型编号',
+ `typeName` VARCHAR(45) NULL COMMENT '类型名称',
+ `price` VARCHAR(20) NULL COMMENT '价格',
+ `splicPrice` VARCHAR(20) NULL COMMENT '拼房价格',
+ `exceedance` INT NULL COMMENT '可超预定数',
+ `isSplice` VARCHAR(10) NULL COMMENT '是否可拼房',
+ PRIMARY KEY (`typeId`));
+
+-- 客房信息
+CREATE TABLE `hotelbook`.`roomInfo` (
+ `roomId` VARCHAR(45) NOT NULL COMMENT '客房编号',
+ `typeId` VARCHAR(45) NOT NULL COMMENT '类型编号',
+ `floorId` INT NOT NULL COMMENT '楼层编号',
+ `ratedNum` INT NULL COMMENT '额定人数',
+ `bedNum` INT NULL COMMENT '床数',
+ `roomDescription` VARCHAR(45) NULL COMMENT '客房描述',
+ `remark` VARCHAR(100) NULL COMMENT '备注',
+ `status` VARCHAR(10) NULL COMMENT '状态',
+ `isSplice` VARCHAR(10) NULL COMMENT '是否可拼房',
+ PRIMARY KEY (`roomId`),
+ INDEX `fk_roomInfo_1_idx` (`typeId` ASC),
+ INDEX `fk_roomInfo_2_idx` (`floorId` ASC),
+ CONSTRAINT `fk_roomInfo_1`
+ FOREIGN KEY (`typeId`)
+ REFERENCES `hotelbook`.`roomType` (`typeId`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION,
+ CONSTRAINT `fk_roomInfo_2`
+ FOREIGN KEY (`floorId`)
+ REFERENCES `hotelbook`.`floorInfo` (`floorId`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION);
+
+-- 预订单
+CREATE TABLE `hotelbook`.`orderInfo` (
+ `orderId` VARCHAR(45) NOT NULL COMMENT '预定单号',
+ `orderName` VARCHAR(45) NULL COMMENT '预定人',
+ `orderPhone` VARCHAR(45) NULL COMMENT '联系电话',
+ `orderIDcard` VARCHAR(18) NULL COMMENT '身份证号',
+ `typeId` VARCHAR(45) NOT NULL COMMENT '客房类型',
+ `arrireDate` VARCHAR(45) NULL COMMENT '抵店时间',
+ `leaveDate` VARCHAR(45) NULL COMMENT '离店时间',
+ `orderState` VARCHAR(20) NULL COMMENT '单据状态',
+ `checkNum` VARCHAR(45) NULL COMMENT '入住人数',
+ `roomId` VARCHAR(45) NULL COMMENT '客房编号',
+ `price` VARCHAR(20) NULL COMMENT '客房价格',
+ `checkPrice` VARCHAR(20) NULL COMMENT '入住价格',
+ `discount` INT NULL COMMENT '折扣',
+ `discountReason` VARCHAR(60) NULL COMMENT '折扣原因',
+ `addBed` VARCHAR(10) NULL COMMENT '是否加床',
+ `addBedPrice` VARCHAR(20) NULL COMMENT '加床价格',
+ `orderMoney` VARCHAR(20) NULL COMMENT '预收款',
+ `remark` VARCHAR(500) NULL COMMENT '备注',
+ `operatorId` VARCHAR(45) NULL COMMENT '操作员',
+ PRIMARY KEY (`orderId`),
+ INDEX `fk_orderInfo_1_idx` (`typeId` ASC),
+ CONSTRAINT `fk_orderInfo_1`
+ FOREIGN KEY (`typeId`)
+ REFERENCES `hotelbook`.`roomType` (`typeId`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION);
+
+-- 入住单
+CREATE TABLE `hotelbook`.`checkInInfo` (
+ `checkId` VARCHAR(45) NOT NULL COMMENT '入住单号',
+ `orderId` VARCHAR(45) NULL COMMENT '预定单号',
+ `checkName` VARCHAR(45) NULL COMMENT '入住人',
+ `checkPhone` VARCHAR(45) NULL COMMENT '联系电话',
+ `checkIDcard` VARCHAR(18) NULL COMMENT '身份证号',
+ `typeId` VARCHAR(45) NOT NULL COMMENT '客房类型',
+ `arrireTime` VARCHAR(45) NULL COMMENT '抵店时间',
+ `leaveTime` VARCHAR(45) NULL COMMENT '离店时间',
+ `checkState` VARCHAR(20) NULL COMMENT '单据状态',
+ `checkNum` INT NULL COMMENT '入住人数',
+ `roomId` VARCHAR(45) NOT NULL COMMENT '客房编号',
+ `price` VARCHAR(20) NULL COMMENT '客房价格',
+ `checkPrice` VARCHAR(20) NULL COMMENT '入住价格',
+ `discount` INT NULL COMMENT '折扣',
+ `discountReason` VARCHAR(60) NULL COMMENT '折扣原因',
+ `addBed` VARCHAR(10) NULL COMMENT '是否加床',
+ `addBedPrice` VARCHAR(20) NULL COMMENT '加床价格',
+ `orderMoney` VARCHAR(20) NULL COMMENT '预收款',
+ `money` VARCHAR(20) NULL COMMENT '应收账款',
+ `isCheck` VARCHAR(10) NULL COMMENT '是否结账',
+ `checkMoney` VARCHAR(20) NULL COMMENT '结账金额',
+ `checkDate` VARCHAR(45) NULL COMMENT '结账日期',
+ `remark` VARCHAR(500) NULL COMMENT '备注',
+ `operatorId` VARCHAR(45) NULL COMMENT '操作员',
+ PRIMARY KEY (`checkId`),
+ INDEX `fk_checkInfo_1_idx` (`typeId` ASC),
+ INDEX `fk_checkInfo_2_idx` (`roomId` ASC),
+ CONSTRAINT `fk_checkInfo_1`
+ FOREIGN KEY (`typeId`)
+ REFERENCES `hotelbook`.`roomType` (`typeId`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION,
+ CONSTRAINT `fk_checkInfo_2`
+ FOREIGN KEY (`roomId`)
+ REFERENCES `hotelbook`.`roomInfo` (`roomId`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION);
+
+-- 账单明细
+CREATE TABLE `hotelbook`.`billInfo` (
+ `billId` INT NOT NULL COMMENT '账单编号',
+ `checkId` VARCHAR(45) NOT NULL COMMENT '入住单号',
+ `costMoney` VARCHAR(20) NULL COMMENT '消费金额',
+ `costDate` VARCHAR(45) NULL COMMENT '消费时间',
+ `remark` VARCHAR(100) NULL COMMENT '备注',
+ PRIMARY KEY (`billId`),
+ INDEX `fk_billInfo_1_idx` (`checkId` ASC),
+ CONSTRAINT `fk_billInfo_1`
+ FOREIGN KEY (`checkId`)
+ REFERENCES `hotelbook`.`checkInInfo` (`checkId`)
+ ON DELETE NO ACTION
+ ON UPDATE NO ACTION);
+
+-- 权限管理
+CREATE TABLE `hotelbook`.`authInfo` (
+ `authId` INT NOT NULL AUTO_INCREMENT COMMENT '权限编号',
+ `authItem` VARCHAR(45) NULL COMMENT '权限项',
+ `isRead` VARCHAR(45) NULL COMMENT '可读',
+ `isWrite` VARCHAR(45) NULL COMMENT '可写',
+ `isChange` VARCHAR(45) NULL COMMENT '可改',
+ `isDelete` VARCHAR(45) NULL COMMENT '可删',
+ PRIMARY KEY (`authId`));
+
diff --git a/src/test/java/com/inks/hb/authinfo/dao/AuthInfoDaoTest.java b/src/test/java/com/inks/hb/authinfo/dao/AuthInfoDaoTest.java
new file mode 100644
index 0000000..427f323
--- /dev/null
+++ b/src/test/java/com/inks/hb/authinfo/dao/AuthInfoDaoTest.java
@@ -0,0 +1,26 @@
+package com.inks.hb.authinfo.dao;
+
+import com.inks.hb.authinfo.pojo.AuthInfo;
+import org.junit.Test;
+
+import java.sql.SQLException;
+
+import static org.junit.Assert.*;
+
+public class AuthInfoDaoTest {
+
+ private AuthInfoDao dao = new AuthInfoDao();
+
+ @Test
+ public void insertData() {
+ AuthInfo authInfo;
+ for (int i = 0;i < 100; i++) {
+ authInfo = new AuthInfo(i,"测试" + i, "1","1",""+i,"0");
+ try {
+ dao.insertData(authInfo);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/inks/hb/common/ExportExcelTest.java b/src/test/java/com/inks/hb/common/ExportExcelTest.java
new file mode 100644
index 0000000..ac889c5
--- /dev/null
+++ b/src/test/java/com/inks/hb/common/ExportExcelTest.java
@@ -0,0 +1,21 @@
+package com.inks.hb.common;
+
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+public class ExportExcelTest {
+
+ @Test
+ public void readXlsx() {
+ try {
+ ArrayList list = ExportExcel.readXlsx("D:\\用户信息.xlsx");
+ for (Object i : list)
+ System.out.println(i.toString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/inks/hb/common/MD5Test.java b/src/test/java/com/inks/hb/common/MD5Test.java
new file mode 100644
index 0000000..afffd57
--- /dev/null
+++ b/src/test/java/com/inks/hb/common/MD5Test.java
@@ -0,0 +1,16 @@
+package com.inks.hb.common;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class MD5Test {
+ private MD5 md5 = new MD5();
+
+ @Test
+ public void checkMD5() {
+ String a = md5.getMD5("toor");
+ System.out.println(a);
+ System.out.println(md5.checkMD5("toor",a));
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/inks/hb/floorinfo/dao/FloorInfoDaoTest.java b/src/test/java/com/inks/hb/floorinfo/dao/FloorInfoDaoTest.java
new file mode 100644
index 0000000..519f773
--- /dev/null
+++ b/src/test/java/com/inks/hb/floorinfo/dao/FloorInfoDaoTest.java
@@ -0,0 +1,20 @@
+package com.inks.hb.floorinfo.dao;
+
+import com.inks.hb.floorinfo.pojo.FloorInfo;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class FloorInfoDaoTest {
+ @Test
+ public void insertData() throws Exception {
+ FloorInfoDao dao = new FloorInfoDao();
+ FloorInfo floorInfo;
+ for (int i = 0; i < 100; i++) {
+ floorInfo = new FloorInfo(i, "123546");
+ dao.insertData(floorInfo);
+
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/com/inks/hb/login/service/LoginServiceImplTest.java b/src/test/java/com/inks/hb/login/service/LoginServiceImplTest.java
new file mode 100644
index 0000000..15c63dc
--- /dev/null
+++ b/src/test/java/com/inks/hb/login/service/LoginServiceImplTest.java
@@ -0,0 +1,42 @@
+package com.inks.hb.login.service;
+
+import com.inks.hb.login.pojo.Login;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class LoginServiceImplTest {
+
+ @Test
+ public void queryByName() {
+ }
+
+ @Test
+ public void queryLogin() {
+ }
+
+ @Test
+ public void insertLogin() {
+
+ Login login = new Login("admin","123456","测试账户");
+
+ int code = new LoginServiceImpl().insertLogin(login);
+ System.out.println("code: " + code);
+ }
+
+ @Test
+ public void deleteLogin() {
+ }
+
+ @Test
+ public void updateLogin() {
+ }
+
+ @Test
+ public void query() {
+ }
+
+ @Test
+ public void queryLoginNum() {
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/inks/hb/orderinfo/dao/OrderInfoDaoTest.java b/src/test/java/com/inks/hb/orderinfo/dao/OrderInfoDaoTest.java
new file mode 100644
index 0000000..d8407f5
--- /dev/null
+++ b/src/test/java/com/inks/hb/orderinfo/dao/OrderInfoDaoTest.java
@@ -0,0 +1,48 @@
+package com.inks.hb.orderinfo.dao;
+
+import com.inks.hb.login.dao.LoginDao;
+import com.inks.hb.login.pojo.Login;
+import com.inks.hb.orderinfo.pojo.OrderInfo;
+import com.inks.hb.roomtype.dao.RoomTypeDao;
+import com.inks.hb.roomtype.pojo.RoomType;
+import org.junit.Test;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import static org.junit.Assert.*;
+
+public class OrderInfoDaoTest {
+
+ OrderInfoDao dao = new OrderInfoDao();
+ RoomTypeDao roomTypeDao = new RoomTypeDao();
+ LoginDao loginDao = new LoginDao();
+
+ @Test
+ public void insertData() throws Exception {
+
+ OrderInfo orderInfo = new OrderInfo();
+ RoomType roomType = roomTypeDao.queryName("123");
+ Login login = (Login) loginDao.query(new Login("root",""));
+ System.out.println(login);
+ orderInfo.setTypeId(roomType);
+ orderInfo.setOperatorId(login);
+ orderInfo.setOrderId("预定第3单");
+ dao.insertData(orderInfo);
+
+ }
+
+ @Test
+ public void queryOrder(){
+ ArrayList list = null;
+ try {
+ list = dao.queryOrder(1,"测试");
+ for (OrderInfo info : list)
+ System.out.println(info);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/com/inks/hb/orderinfo/service/OrderInfoServiceImplTest.java b/src/test/java/com/inks/hb/orderinfo/service/OrderInfoServiceImplTest.java
new file mode 100644
index 0000000..8de33c7
--- /dev/null
+++ b/src/test/java/com/inks/hb/orderinfo/service/OrderInfoServiceImplTest.java
@@ -0,0 +1,50 @@
+package com.inks.hb.orderinfo.service;
+
+import com.inks.hb.orderinfo.pojo.OrderInfo;
+import org.junit.Test;
+
+import java.util.ArrayList;
+
+import static org.junit.Assert.*;
+
+public class OrderInfoServiceImplTest {
+
+ private OrderInfoService service = new OrderInfoServiceImpl();
+
+ @Test
+ public void insertOrderInfo() {
+ }
+
+ @Test
+ public void deleteOrderInfo() {
+ }
+
+ @Test
+ public void updateOrderInfo() {
+ }
+
+ @Test
+ public void query() {
+
+ ArrayList list = service.query(1,50);
+
+ for (OrderInfo info : list) {
+ System.out.println(info);
+ }
+
+ }
+
+ @Test
+ public void query1() {
+
+ System.out.println(service.query("OD151254780333"));
+ }
+
+ @Test
+ public void queryOrderInfoNum() {
+ }
+
+ @Test
+ public void queryRepeat() {
+ }
+}
\ No newline at end of file
diff --git a/src/test/test.iml b/src/test/test.iml
new file mode 100644
index 0000000..a56556f
--- /dev/null
+++ b/src/test/test.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/webapp/404.htm b/src/webapp/404.htm
new file mode 100644
index 0000000..0a084a2
--- /dev/null
+++ b/src/webapp/404.htm
@@ -0,0 +1,147 @@
+
+
+
+
+ 404错误页面
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
啊~哦~ 您要查看的页面不存在或已删除!
+
+
+
+
+
+
+
+
+