develop
wht 10 months ago
parent cb98363813
commit 49b35b2252

8
.idea/.gitignore vendored

@ -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

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/webapp/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/src/webapp" relative="/" />
</webroots>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,34 @@
<component name="libraryTable">
<library name="lib">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/commons-io-1.4.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/base64-1.2.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/hamcrest-core-1.3.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/javax.servlet.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/javax.annotation.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/commons-collections4-4.1.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/javax.servlet.jsp.jstl.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/commons-fileupload-1.2.1.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/mchange-commons-java-0.2.11.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/poi-scratchpad-3.17.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/poi-3.17.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/gson-2.2.4.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/poi-examples-3.17.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/xmlbeans-2.6.0.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/javax.ejb.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/javax.persistence.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/javax.resource.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/poi-ooxml-3.17.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/junit-4.12.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/javax.transaction.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/mysql-connector-java-5.1.44-bin.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/javax.jms.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/poi-ooxml-schemas-3.17.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/c3p0-0.9.5.2.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/javax.servlet.jsp.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/poi-excelant-3.17.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" project-jdk-name="21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/hotelbook-JavaWeb-master.iml" filepath="$PROJECT_DIR$/.idea/hotelbook-JavaWeb-master.iml" />
<module fileurl="file://$PROJECT_DIR$/src/main/main.iml" filepath="$PROJECT_DIR$/src/main/main.iml" />
<module fileurl="file://$PROJECT_DIR$/src/test/test.iml" filepath="$PROJECT_DIR$/src/test/test.iml" />
</modules>
</component>
</project>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/touge" vcs="Git" />
<mapping directory="$PROJECT_DIR$/touge/hotelbook-JavaWeb-master" vcs="Git" />
</component>
</project>

@ -1,2 +1,13 @@
# hotelbook-JavaWeb-master ## 酒店管理系统
> 项目具体说明:简单的酒店管理系统。
### 基础环境:
- Tomcat9
- Java 1.8+
- Mysql/Mariadb
### 描述:
很简陋的小项目真的很简陋关于部署Tomcat 务必为 9.XJDK 可 12数据库文件位于 `~/src/sql/` 中,初始登录用户密码为:`root`/`toor`Tomcat 应用上下文为 `/hb`;项目依赖:`lib` 目录。

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/webapp/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/src/webapp" relative="/" />
</webroots>
<sourceRoots>
<root url="file://$MODULE_DIR$/src/main/java" />
<root url="file://$MODULE_DIR$/src/main/resources" />
<root url="file://$MODULE_DIR$/lib" />
<root url="file://$MODULE_DIR$/src" />
</sourceRoots>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/lib" type="java-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="Java EE 6-Java EE 6" level="project" />
<orderEntry type="library" exported="" scope="PROVIDED" name="Tomcat 10.0.18" level="application_server_libraries" />
<orderEntry type="library" exported="" name="lib" level="project" />
</component>
<component name="sonarModuleSettings">
<option name="localAnalysisScripName" value="&lt;PROJECT&gt;" />
<option name="serverName" value="&lt;PROJECT&gt;" />
</component>
</module>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -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<AuthInfo> infoArrayList = null;
try {
infoArrayList = service.query(1, service.queryAuthInfoNum());
} catch (SQLException e) {
e.printStackTrace();
}
String[] headers = {"权限ID", "权限名称", "可读", "可写", "可改", "可删"};
String fileName = "权限信息";
ExportExcel<AuthInfo> ee = new ExportExcel<>();
ee.exportExcel(headers, infoArrayList, fileName, response);
}
}

@ -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<AuthInfo> 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));
}
}
}

@ -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<AuthInfo> 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<AuthInfo> 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;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save