commit
3e340d09d1
@ -0,0 +1,83 @@
|
||||
<%@page import="javabean.Util"%>
|
||||
<%@page import="javabean.Base"%>
|
||||
<%@page import="java.sql.ResultSet"%>
|
||||
<%@page import="java.sql.PreparedStatement"%>
|
||||
<%@page import="com.mysql.jdbc.Connection"%>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>书籍借阅历史</title>
|
||||
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
|
||||
<script src="../public/layui/layui.js" charset="utf-8"></script>
|
||||
<style>
|
||||
.layui-table, .layui-table-view{
|
||||
margin-top: 0px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<%
|
||||
String id = request.getParameter("id");
|
||||
String name = request.getParameter("name");
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet resultSet = null;
|
||||
String sql = "select * from borrow_books,borrow_card where book_id=? and card_id=borrow_card.id order by borrow_books.id desc";
|
||||
connection = (Connection)Base.getConnection();
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setString(1,id);
|
||||
resultSet = pstmt.executeQuery();
|
||||
/* while(resultSet.next()){
|
||||
out.print(resultSet.getString("id"));
|
||||
}*/
|
||||
%>
|
||||
<div class="layui-form">
|
||||
<table class="layui-table">
|
||||
<colgroup>
|
||||
<col width="150">
|
||||
<col width="150">
|
||||
<col width="200">
|
||||
<col width="200">
|
||||
<col width="200">
|
||||
<col width="200">
|
||||
<col width="220">
|
||||
<col width="200">
|
||||
<col width="200">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>书籍ID</th>
|
||||
<th>书籍名</th>
|
||||
<th>借阅证</th>
|
||||
<th>借阅者</th>
|
||||
<th>借阅时间</th>
|
||||
<th>归还时间</th>
|
||||
<th>违规信息</th>
|
||||
<th>处理人</th>
|
||||
</tr>
|
||||
<%while(resultSet.next()){ %>
|
||||
<tr>
|
||||
<td><%=resultSet.getString("id") %></td>
|
||||
<td><%=id %></td>
|
||||
<td><%=name %></td>
|
||||
<td><%=resultSet.getString("borrow_card.id") %></td>
|
||||
<td><%=resultSet.getString("reader") %></td>
|
||||
<td><%=Util.getFormatDateTime(resultSet.getString("borrow_date")) %></td>
|
||||
<td><%=resultSet.getString("return_date") != null? Util.getFormatDateTime(resultSet.getString("return_date")) : "" %></td>
|
||||
<td><%=resultSet.getString("illegal") != null? resultSet.getString("illegal") : "" %></td>
|
||||
<td><%=resultSet.getString("manager_id") != null? resultSet.getString("manager_id") : "" %></td>
|
||||
</tr>
|
||||
<%} %>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,92 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>借阅记录</title>
|
||||
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
|
||||
<style>
|
||||
.layui-table,.layui-table-view{
|
||||
margin: 0 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<script src="../public/layui/layui.js" charset="utf-8"></script>
|
||||
<!-- 表单 -->
|
||||
<table class="layui-hide" id="history" lay-filter="formFilter"></table>
|
||||
|
||||
<!-- 头部工具栏 -->
|
||||
<script type="text/html" id="headBar">
|
||||
条件搜索:
|
||||
<div class="layui-inline">
|
||||
<select id="condition" name="condition" lay-verify="required">
|
||||
<option value=""></option>
|
||||
<option value="other">超期未还</option>
|
||||
<option value="id">ID</option>
|
||||
<option value="card_id">借阅证号</option>
|
||||
<option value="book_id">书籍ID</option>
|
||||
<option value="borrow_date">借阅日期</option>
|
||||
<option value="end_date">限制日期</option>
|
||||
<option value="return_date">返还日期</option>
|
||||
<option value="illegal">违章信息</option>
|
||||
<option value="manager_id">处理人</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<input class="layui-input" id="conditionValue" name="conditionValue" id="demoReload" autocomplete="off">
|
||||
</div>
|
||||
<button class="layui-btn" name="condition" data-type="reload" lay-event="search">搜索</button>
|
||||
</script>
|
||||
<script>
|
||||
layui.use(['table','jquery'], function(){
|
||||
$ = layui.jquery;
|
||||
var table = layui.table;
|
||||
// 进行渲染
|
||||
var tableIns = table.render({
|
||||
elem: '#history'
|
||||
,url:'./borrowList'
|
||||
,toolbar: '#headBar'
|
||||
,cols: [[
|
||||
{field:'id', width:80, title: 'ID', sort: true}
|
||||
,{field:'card_id', width:180, title: '借阅证号'}
|
||||
,{field:'book_id', width:100, title: '书籍ID', sort: true}
|
||||
,{field:'borrow_date', width:180, title: '借阅时间'}
|
||||
,{field:'end_date', title: '限定时间', width: 180}
|
||||
,{field:'return_date', width:180, title: '归还时间', sort: true}
|
||||
,{field:'illegal', minWidth:280, title: '违章信息', sort: true}
|
||||
,{field:'manager_id', width:80, title: '处理人'}
|
||||
]]
|
||||
,page: true
|
||||
});
|
||||
|
||||
// 头部工具栏事件
|
||||
table.on('toolbar(formFilter)', function(obj){
|
||||
var checkStatus = table.checkStatus(obj.config.id);
|
||||
switch(obj.event){
|
||||
// 条件查找图书证
|
||||
case 'search':
|
||||
var conditionValue = $('#conditionValue');
|
||||
var condition = $('#condition');
|
||||
// 进行搜索,重新渲染
|
||||
tableIns.reload({
|
||||
where: { //设定异步数据接口的额外参数,任意设
|
||||
"condition": condition.val(),
|
||||
"conditionValue": conditionValue.val()
|
||||
}
|
||||
,page: {
|
||||
curr: 1 //重新从第 1 页开始
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,117 @@
|
||||
<%@page import="javabean.Base"%>
|
||||
<%@page import="java.sql.ResultSet"%>
|
||||
<%@page import="java.sql.PreparedStatement"%>
|
||||
<%@page import="com.mysql.jdbc.Connection"%>
|
||||
<%@page import="net.sf.json.JSONObject"%>
|
||||
<%@page import="net.sf.json.JSONArray"%>
|
||||
<%@page import="javabean.Admin"%>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>图书证修改</title>
|
||||
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
|
||||
<script src="../public/layui/layui.js" charset="utf-8"></script>
|
||||
<style>
|
||||
.layui-form{
|
||||
margin: 10px 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<%
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet ruleSet = null;
|
||||
String sql = "select * from rules";
|
||||
String result = "";
|
||||
connection = (Connection)Base.getConnection();
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
ruleSet = pstmt.executeQuery();
|
||||
%>
|
||||
<form class="layui-form layui-form-pane" action="" lay-filter="cardFilter">
|
||||
<!-- 姓名 -->
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">姓名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="reader" lay-verify="required" autocomplete="off" placeholder="请输入姓名" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 密码 -->
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="password" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 借阅规则 -->
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">规则</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="rule_id" lay-filter="rule_id" lay-verify="required">
|
||||
<% while(ruleSet.next()){ %>
|
||||
<option value=<%=ruleSet.getString("id") %>><%=ruleSet.getString("id") %></option>
|
||||
<%} %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="status" value="1" title="可用" checked="">
|
||||
<input type="radio" name="status" value="0" title="挂失">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit="" lay-filter="submitForm">立即提交</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'jquery'], function(){
|
||||
var form = layui.form
|
||||
,layer = layui.layer;
|
||||
$ = layui.jquery;
|
||||
// 提交表单
|
||||
form.on('submit(submitForm)', function(data){
|
||||
$.ajax({
|
||||
url: './cardAdd',
|
||||
method: 'post',
|
||||
data: data.field,
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
if(data.code == "0"){
|
||||
parent.layer.open({
|
||||
title: '注册账号为',
|
||||
content: data.data['id'],
|
||||
end: function(){
|
||||
//parent.location.reload();
|
||||
var index = parent.layer.getFrameIndex(window.name); //操作父页面
|
||||
parent.layer.close(index);
|
||||
}
|
||||
});
|
||||
/*setTimeout(function(){
|
||||
|
||||
}, 500);*/
|
||||
}else{
|
||||
leyer.msg("添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
return false;
|
||||
})
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,83 @@
|
||||
<%@page import="javabean.Util"%>
|
||||
<%@page import="java.sql.PreparedStatement"%>
|
||||
<%@page import="com.mysql.jdbc.Connection"%>
|
||||
<%@page import="javabean.Base"%>
|
||||
<%@page import="java.sql.ResultSet"%>
|
||||
<%@page import="javabean.JDBCBean"%>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>借阅证借阅记录</title>
|
||||
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
|
||||
<script src="../public/layui/layui.js" charset="utf-8"></script>
|
||||
<style>
|
||||
.layui-table,.layui-table-view{
|
||||
margin: 0 0px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<%
|
||||
String id = request.getParameter("id");
|
||||
Connection connection = (Connection)Base.getConnection();
|
||||
String sql = "select * from borrow_books,books where card_id=? and borrow_books.book_id = books.id";
|
||||
PreparedStatement pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setString(1, id);
|
||||
ResultSet resultSet = null;
|
||||
resultSet = pstmt.executeQuery();
|
||||
|
||||
%>
|
||||
<div class="layui-form">
|
||||
<table class="layui-table">
|
||||
<colgroup>
|
||||
<col width="150">
|
||||
<col width="150">
|
||||
<col width="200">
|
||||
<col width="200">
|
||||
<col width="200">
|
||||
<col width="200">
|
||||
<col width="220">
|
||||
<col width="200">
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>书籍ID</th>
|
||||
<th>书籍名</th>
|
||||
<th>借阅时间</th>
|
||||
<th>截止时间</th>
|
||||
<th>归还时间</th>
|
||||
<th>违规信息</th>
|
||||
<th>处理人</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%
|
||||
System.out.println(Util.getCurrentTimeString());
|
||||
%>
|
||||
<% while(resultSet.next()){ %>
|
||||
<%-- 图书超期 --%>
|
||||
<%if(Util.getFormatDateTime(resultSet.getString("end_date")).compareTo(Util.getCurrentTimeString()) < 0 && resultSet.getString("return_date") == null){ %>
|
||||
<tr style="color:#FF5722;">
|
||||
<%} else{ %>
|
||||
<tr>
|
||||
<%} %>
|
||||
<td><%=resultSet.getString("card_id") %></td>
|
||||
<td><%=resultSet.getString("id") %></td>
|
||||
<td><%=resultSet.getString("books.name") %></td>
|
||||
<td><%=Util.getFormatDateTime(resultSet.getString("borrow_date")) %></td>
|
||||
<td><%=Util.getFormatDateTime(resultSet.getString("end_date"))%></td>
|
||||
<td><%=resultSet.getString("return_date")!=null?Util.getFormatDateTime(resultSet.getString("return_date")) : "未归还" %></td>
|
||||
<td><%=resultSet.getString("illegal")!=null?resultSet.getString("illegal"):""%></td>
|
||||
<td><%=resultSet.getString("manager_id")!=null?resultSet.getString("manager_id"):"" %></td>
|
||||
</tr>
|
||||
<%} %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,157 @@
|
||||
<%@page import="javabean.Base"%>
|
||||
<%@page import="java.sql.ResultSet"%>
|
||||
<%@page import="java.sql.PreparedStatement"%>
|
||||
<%@page import="com.mysql.jdbc.Connection"%>
|
||||
<%@page import="net.sf.json.JSONObject"%>
|
||||
<%@page import="net.sf.json.JSONArray"%>
|
||||
<%@page import="javabean.Admin"%>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>图书证修改</title>
|
||||
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
|
||||
<script src="../public/layui/layui.js" charset="utf-8"></script>
|
||||
<style>
|
||||
.layui-form{
|
||||
margin: 10px 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<%
|
||||
// 获取借阅证信息
|
||||
String id = request.getParameter("id");
|
||||
|
||||
|
||||
// 获取rule
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
PreparedStatement infoPstmt = null;
|
||||
ResultSet ruleSet = null;
|
||||
ResultSet infoSet = null;
|
||||
String sql = "select * from rules";
|
||||
String infoSql = "select * from borrow_card where id=?";
|
||||
String result = "";
|
||||
// 公用连接
|
||||
connection = (Connection)Base.getConnection();
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
infoPstmt = connection.prepareStatement(infoSql);
|
||||
infoPstmt.setString(1,id);
|
||||
infoSet = infoPstmt.executeQuery();
|
||||
infoSet.next();
|
||||
ruleSet = pstmt.executeQuery();
|
||||
%>
|
||||
<form class="layui-form layui-form-pane" action="" lay-filter="cardFilter">
|
||||
|
||||
<!-- 账号 -->
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">账号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="id" value=<%=id %> class="layui-input" disabled>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 姓名 -->
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">姓名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="reader" value=<%=infoSet.getString("reader") %> lay-verify="required" autocomplete="off" placeholder="请输入姓名" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 密码 -->
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="password" name="password" value=<%=infoSet.getString("reader") %> placeholder="请输入密码" autocomplete="off" class="layui-input" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 借阅规则 -->
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">规则</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="rule_id" lay-filter="rule_id" lay-verify="required">
|
||||
<% while(ruleSet.next()){ %>
|
||||
<option value=<%=ruleSet.getString("id") %> <%if(ruleSet.getString("id").equals(infoSet.getString("rule_id"))) out.print("selected"); %>><%=ruleSet.getString("id") %></option>
|
||||
<%} %>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="status" value="1" title="可用" <%if(infoSet.getString("status").equals("1")) out.print("checked"); %>>
|
||||
<input type="radio" name="status" value="0" title="挂失" <%if(infoSet.getString("status").equals("0")) out.print("checked"); %>>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit="" lay-filter="submitForm">立即提交</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'jquery'], function(){
|
||||
var form = layui.form
|
||||
,layer = layui.layer;
|
||||
$ = layui.jquery;
|
||||
// 提交表单
|
||||
form.on('submit(submitForm)', function(data){
|
||||
$.ajax({
|
||||
url: './cardEdit',
|
||||
type: 'post',
|
||||
data: data.field,
|
||||
dataType: 'json',
|
||||
timeout : 3000,
|
||||
success: function(data){
|
||||
if(data.code == "0"){
|
||||
layer.msg("修改成功", {
|
||||
icon: 6,
|
||||
anim: 5,
|
||||
time: 500,
|
||||
});
|
||||
|
||||
setTimeout(function(){
|
||||
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
|
||||
parent.layer.close(index); //再执行关闭
|
||||
}, 500)
|
||||
/*
|
||||
parent.layer.open({
|
||||
title: '注册账号为',
|
||||
content: data.data['id'],
|
||||
end: function(){
|
||||
parent.location.reload();
|
||||
}
|
||||
});
|
||||
*/
|
||||
/*setTimeout(function(){
|
||||
parent.location.reload();
|
||||
}, 500);*/
|
||||
}else{
|
||||
leyer.msg("添加失败");
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
layer.msg("获取超时");
|
||||
}
|
||||
|
||||
});
|
||||
return false;
|
||||
})
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<%
|
||||
Base.closeResource(connection, pstmt, ruleSet);
|
||||
%>
|
||||
</body>
|
||||
</html>
|
@ -1 +1 @@
|
||||
{"code":0,"msg":"","count":10,"data":[{"id":10000,"name":"夏洛特的烦恼","library_name":"南图","sort_id":"言情","position_id":"sdf","state":"借出","descript":"好看","operate":"234"},{"id":10000,"name":"夏洛特的烦恼","library_name":"南图","sort_id":"言情","position_id":"sdf","state":"借出","descript":"好看","operate":"234"},{"id":10000,"name":"夏洛特的烦恼","library_name":"南图","sort_id":"言情","position_id":"sdf","state":"借出","descript":"好看","operate":"234"},{"id":10010,"name":"夏洛特的烦恼","library_name":"南图","sort_id":"言情","position_id":"sdf","state":"借出","descript":"好看","operate":"234"}]}
|
||||
{"code":0,"msg":"","data":[{"id":10020,"username":"user-20","sex":"男","city":"城市-20","sign":"签名-20","experience":770,"logins":24,"wealth":92420248,"classify":"诗人","score":87},{"id":10021,"username":"user-21","sex":"男","city":"城市-21","sign":"签名-21","experience":184,"logins":131,"wealth":71566045,"classify":"词人","score":99},{"id":10022,"username":"user-22","sex":"男","city":"城市-22","sign":"签名-22","experience":739,"logins":152,"wealth":60907929,"classify":"作家","score":18},{"id":10023,"username":"user-23","sex":"女","city":"城市-23","sign":"签名-23","experience":127,"logins":82,"wealth":14765943,"classify":"作家","score":30},{"id":10024,"username":"user-24","sex":"女","city":"城市-24","sign":"签名-24","experience":212,"logins":133,"wealth":59011052,"classify":"词人","score":76},{"id":10025,"username":"user-25","sex":"女","city":"城市-25","sign":"签名-25","experience":938,"logins":182,"wealth":91183097,"classify":"作家","score":69},{"id":10026,"username":"user-26","sex":"男","city":"城市-26","sign":"签名-26","experience":978,"logins":7,"wealth":48008413,"classify":"作家","score":65},{"id":10027,"username":"user-27","sex":"女","city":"城市-27","sign":"签名-27","experience":371,"logins":44,"wealth":64419691,"classify":"诗人","score":60},{"id":10028,"username":"user-28","sex":"女","city":"城市-28","sign":"签名-28","experience":977,"logins":21,"wealth":75935022,"classify":"作家","score":37},{"id":10029,"username":"user-29","sex":"男","city":"城市-29","sign":"签名-29","experience":647,"logins":107,"wealth":97450636,"classify":"酱油","score":27},{"id":10029,"username":"user-29","sex":"男","city":"城市-29","sign":"签名-29","experience":647,"logins":107,"wealth":97450636,"classify":"酱油","score":27},{"id":10029,"username":"user-29","sex":"男","city":"城市-29","sign":"签名-29","experience":647,"logins":107,"wealth":97450636,"classify":"酱油","score":27},{"id":10029,"username":"user-29","sex":"男","city":"城市-29","sign":"签名-29","experience":647,"logins":107,"wealth":97450636,"classify":"酱油","score":27},{"id":10029,"username":"user-29","sex":"男","city":"城市-29","sign":"签名-29","experience":647,"logins":107,"wealth":97450636,"classify":"酱油","score":27},{"id":10029,"username":"user-29","sex":"男","city":"城市-29","sign":"签名-29","experience":647,"logins":107,"wealth":97450636,"classify":"酱油","score":27},{"id":10029,"username":"user-29","sex":"男","city":"城市-29","sign":"签名-29","experience":647,"logins":107,"wealth":97450636,"classify":"酱油","score":27},{"id":10029,"username":"user-29","sex":"男","city":"城市-29","sign":"签名-29","experience":647,"logins":107,"wealth":97450636,"classify":"酱油","score":27}]}
|
@ -1,3 +0,0 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
managelist.html
|
@ -0,0 +1,90 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>管理员添加</title>
|
||||
<!-- layui -->
|
||||
<link rel="stylesheet" href="../public/layui/css/layui.css">
|
||||
<script src="../public/layui/layui.js"></script>
|
||||
<style>
|
||||
.layui-form{
|
||||
margin: 10px 20px;
|
||||
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
</head>
|
||||
<body>
|
||||
<form class="layui-form layui-form-pane" action="" lay-filter="formFilter">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">姓名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" lay-verify="required" required autocomplete="off" placeholder="请输入姓名" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">账号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="account" lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="password" name="password" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">邮箱</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="email" lay-verify="required" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button type="submit" class="layui-btn" lay-submit="" lay-filter="submitButton">立即提交</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
|
||||
layui.use(['form', 'jquery'], function(){
|
||||
$ = layui.jquery;
|
||||
var form = layui.form
|
||||
,layer = layui.layer
|
||||
//监听提交
|
||||
form.on('submit(submitButton)', function(data){
|
||||
$.ajax({
|
||||
url: './managerAdd',
|
||||
method: 'post',
|
||||
data: data.field,
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
if(data.code == "0"){
|
||||
parent.layer.msg("添加成功",{
|
||||
icon: 6,
|
||||
time: 500
|
||||
});
|
||||
setTimeout(function(){
|
||||
parent.location.reload();
|
||||
}, 500);
|
||||
}else{
|
||||
layer.msg(data.msg);
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,103 @@
|
||||
<%@page import="java.sql.ResultSet"%>
|
||||
<%@page import="java.sql.PreparedStatement"%>
|
||||
<%@page import="com.mysql.jdbc.Connection"%>
|
||||
<%@page import="javabean.Base"%>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>管理员修改</title>
|
||||
<!-- layui -->
|
||||
<link rel="stylesheet" href="../public/layui/css/layui.css">
|
||||
<script src="../public/layui/layui.js"></script>
|
||||
<style>
|
||||
.layui-form{
|
||||
margin: 10px 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
</head>
|
||||
<body>
|
||||
<%
|
||||
String id = request.getParameter("id");
|
||||
Connection connection = (Connection)Base.getConnection();
|
||||
String sql = "select * from manager where id=?";
|
||||
PreparedStatement pstmt = connection.prepareCall(sql);
|
||||
pstmt.setString(1,id);
|
||||
ResultSet resultSet = pstmt.executeQuery();
|
||||
resultSet.next();
|
||||
|
||||
%>
|
||||
<form class="layui-form layui-form-pane" action="" lay-filter="formFilter">
|
||||
<input type="text" name="id" value=<%=id %> lay-verify="required" required autocomplete="off" placeholder="请输入姓名" class="layui-input layui-hide">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">姓名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" value=<%=resultSet.getString("name") %> lay-verify="required" required autocomplete="off" placeholder="请输入姓名" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">账号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="account" value=<%=resultSet.getString("account") %> disabled lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="password" name="password" value=<%=resultSet.getString("password") %> lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">邮箱</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="email" value=<%=resultSet.getString("email") %> lay-verify="required" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button type="submit" class="layui-btn" lay-submit="" lay-filter="submitButton">立即提交</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
|
||||
layui.use(['form', 'jquery'], function(){
|
||||
$ = layui.jquery;
|
||||
var form = layui.form
|
||||
,layer = layui.layer
|
||||
//监听提交
|
||||
form.on('submit(submitButton)', function(data){
|
||||
$.ajax({
|
||||
url: './managerEdit',
|
||||
method: 'post',
|
||||
data: data.field,
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
if(data.code == "0"){
|
||||
parent.layer.msg("添加成功",{
|
||||
icon: 6,
|
||||
time: 500
|
||||
});
|
||||
setTimeout(function(){
|
||||
parent.location.reload();
|
||||
}, 500);
|
||||
}else{
|
||||
layer.msg(data.msg);
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,118 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>借阅卡</title>
|
||||
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
|
||||
<style>
|
||||
.layui-table,.layui-table-view{
|
||||
margin: 0 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<!-- 表单 -->
|
||||
<table class="layui-hide" id="managerTable" lay-filter="formFilter"></table>
|
||||
<script src="../public/layui/layui.js" charset="utf-8"></script>
|
||||
<!-- 头部工具栏 -->
|
||||
<script type="text/html" id="headBar">
|
||||
<button type="button" class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon">添加管理员</i></button>
|
||||
</script>
|
||||
|
||||
<!-- 表格侧边栏 -->
|
||||
<script type="text/html" id="operateBar">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
||||
</script>
|
||||
<script>
|
||||
layui.use(['table','jquery'], function(){
|
||||
$ = layui.jquery;
|
||||
var table = layui.table;
|
||||
// 进行渲染
|
||||
var tableIns = table.render({
|
||||
elem: '#managerTable'
|
||||
,url:'./managerList'
|
||||
,toolbar: '#headBar'
|
||||
,height: 600
|
||||
,cols: [[
|
||||
{field:'id', width:80, title: 'ID', sort: true}
|
||||
,{field:'name', width:80, title: '用户名'}
|
||||
,{field:'account', width:80, title: '账号', sort: true}
|
||||
,{field:'email', title: '邮箱', minWidth: 150}
|
||||
,{fixed: 'right', title:'操作', toolbar: '#operateBar', align: 'center', width:150}
|
||||
]]
|
||||
});
|
||||
|
||||
// 头部工具栏事件
|
||||
table.on('toolbar(formFilter)', function(obj){
|
||||
var checkStatus = table.checkStatus(obj.config.id);
|
||||
switch(obj.event){
|
||||
// 添加管理员
|
||||
case 'add':
|
||||
var addCardLayer = layer.open({
|
||||
type: 2,
|
||||
title: '添加管理员',
|
||||
area: ['800px', '500px'],
|
||||
maxmin: true,
|
||||
shadeClose: true,
|
||||
content: 'manageradd.jsp',
|
||||
});
|
||||
//layer.full(addCardLayer);
|
||||
};
|
||||
});
|
||||
|
||||
// 侧边工具栏事件
|
||||
table.on(('tool(formFilter)'), function(obj){
|
||||
var data = obj.data;
|
||||
var layEvent = obj.event;
|
||||
var id = data.id;
|
||||
var tr = obj.tr;
|
||||
switch(obj.event){
|
||||
case 'edit':
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '更改信息',
|
||||
area: ['800px', '600px'],
|
||||
maxmin: true,
|
||||
shadeClose: true,
|
||||
content: 'manageredit.jsp?id=' +id,
|
||||
})
|
||||
break;
|
||||
case 'del':
|
||||
layer.confirm('确定要删除么?',function(){
|
||||
layer.msg("ok");
|
||||
$.ajax({
|
||||
url: './managerDel',
|
||||
data: 'id=' +id,
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
timeout: 3000,
|
||||
success: function(data){
|
||||
layer.msg("???");
|
||||
if(data.code == 0){
|
||||
layer.msg(data.msg,{
|
||||
icon: 6,
|
||||
anim: 5,
|
||||
time: 500
|
||||
});
|
||||
setTimeout(function(){
|
||||
parent.location.reload();
|
||||
},500);
|
||||
}else{
|
||||
layer.msg(data.code);
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
layer.msg("连接超时");
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,119 @@
|
||||
<%@page import="javabean.Common"%>
|
||||
<%@page import="java.util.TreeMap"%>
|
||||
<%@page import="java.util.HashMap"%>
|
||||
<%@page import="java.util.Map"%>
|
||||
<%@page import="java.util.ArrayList"%>
|
||||
<%@page import="java.sql.ResultSet"%>
|
||||
<%@page import="java.sql.PreparedStatement"%>
|
||||
<%@page import="com.mysql.jdbc.Connection"%>
|
||||
<%@page import="javabean.Base"%>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>规则添加</title>
|
||||
<!-- layui -->
|
||||
<link rel="stylesheet" href="../public/layui/css/layui.css">
|
||||
<script src="../public/layui/layui.js"></script>
|
||||
<style>
|
||||
.layui-form{
|
||||
margin: 10px 20px;
|
||||
|
||||
}
|
||||
.layui-form-pane .layui-form-label{
|
||||
width: 120px;
|
||||
}
|
||||
.layui-form-pane .layui-input-block{
|
||||
margin-left: 120px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<%
|
||||
// 获取图书馆map
|
||||
Map<String, String> libraryMap = Common.getLibraryMap();
|
||||
%>
|
||||
<form class="layui-form layui-form-pane" action="">
|
||||
<input type="id" name="id" value="3" class="layui-hide">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">限制天数</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="limit_day" required lay-verify="required" placeholder="请输入限制天数" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<!-- 作者 -->
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">限制数量</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="borrow_num" required lay-verify="required" placeholder="请输入限制数量" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">限制图书馆</label>
|
||||
<div class="layui-input-block" >
|
||||
<%
|
||||
for(String key : libraryMap.keySet()){
|
||||
%>
|
||||
<input type="checkbox" name=<%="borrow_library[" +key +"]" %> title=<%=libraryMap.get(key) %> checked>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">逾期每天费用</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="overtime_fee" required lay-verify="required" placeholder="请输入逾期每天费用" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit="" lay-filter="submitButton">立即提交</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
|
||||
layui.use(['form', 'jquery'], function(){
|
||||
$ = layui.jquery;
|
||||
var form = layui.form
|
||||
,layer = layui.layer
|
||||
//监听提交
|
||||
form.on('submit(submitButton)', function(data){
|
||||
$.ajax({
|
||||
url: './ruleAdd',
|
||||
method: 'post',
|
||||
data: data.field,
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
if(data.code == "0"){
|
||||
parent.layer.msg("添加成功",{
|
||||
icon: 6,
|
||||
time: 500
|
||||
});
|
||||
setTimeout(function(){
|
||||
parent.location.reload();
|
||||
}, 500);
|
||||
}else{
|
||||
leyer.msg("添加失败");
|
||||
}
|
||||
|
||||
//parent.layer.msg('您将标记 [ sdf ] 成功传送给了父窗口');
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,144 @@
|
||||
<%@page import="javabean.Common"%>
|
||||
<%@page import="java.util.TreeMap"%>
|
||||
<%@page import="java.util.HashMap"%>
|
||||
<%@page import="java.util.Map"%>
|
||||
<%@page import="java.util.ArrayList"%>
|
||||
<%@page import="java.sql.ResultSet"%>
|
||||
<%@page import="java.sql.PreparedStatement"%>
|
||||
<%@page import="com.mysql.jdbc.Connection"%>
|
||||
<%@page import="javabean.Base"%>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>规则添加</title>
|
||||
<!-- layui -->
|
||||
<link rel="stylesheet" href="../public/layui/css/layui.css">
|
||||
<script src="../public/layui/layui.js"></script>
|
||||
<style>
|
||||
.layui-form{
|
||||
margin: 10px 20px;
|
||||
|
||||
}
|
||||
.layui-form-pane .layui-form-label{
|
||||
width: 120px;
|
||||
}
|
||||
.layui-form-pane .layui-input-block{
|
||||
margin-left: 120px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<%
|
||||
String id = request.getParameter("id");
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet resultSet = null;
|
||||
String sql = "";
|
||||
|
||||
connection = (Connection)Base.getConnection();
|
||||
sql = "select * from rules where id = ?";
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setString(1, id);
|
||||
resultSet = pstmt.executeQuery();
|
||||
resultSet.next();
|
||||
|
||||
String[] libraryList = resultSet.getString("borrow_library").split("、");
|
||||
// 获取图书馆map
|
||||
Map<String, String> libraryMap = Common.getLibraryMap();
|
||||
%>
|
||||
<form class="layui-form layui-form-pane" action="">
|
||||
<input type="text" name="id" value=<%=id %> class="layui-hide">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">限制天数</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="limit_day" value=<%=resultSet.getString("limit_day") %> required lay-verify="required" placeholder="请输入限制天数" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<!-- 作者 -->
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">限制数量</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="borrow_num" value=<%=resultSet.getString("borrow_num") %> required lay-verify="required" placeholder="请输入限制数量" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">限制图书馆</label>
|
||||
<div class="layui-input-block" >
|
||||
<%
|
||||
for(String key : libraryMap.keySet()){
|
||||
boolean flag = false;
|
||||
%>
|
||||
<input type="checkbox" name=<%="borrow_library[" +key +"]" %> title=<%=libraryMap.get(key) %>
|
||||
<% for(String key0 : libraryList){
|
||||
flag = false;
|
||||
if(key0.equals(key)){
|
||||
flag = true;
|
||||
}
|
||||
if(flag == true)
|
||||
out.print("checked");
|
||||
}
|
||||
%>>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">逾期每天费用</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="overtime_fee" value=<%=resultSet.getString("overtime_fee") %> required lay-verify="required" placeholder="请输入逾期每天费用" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit="" lay-filter="bookForm">立即提交</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
|
||||
layui.use(['form', 'jquery'], function(){
|
||||
//layer.closeAll();
|
||||
$ = layui.jquery;
|
||||
var form = layui.form
|
||||
,layer = layui.layer
|
||||
//监听提交
|
||||
form.on('submit(bookForm)', function(data){
|
||||
$.ajax({
|
||||
url: './ruleEdit',
|
||||
method: 'post',
|
||||
data: data.field,
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
if(data.code == "0"){
|
||||
parent.layer.msg("修改成功",{
|
||||
icon: 6,
|
||||
time: 500
|
||||
});
|
||||
setTimeout(function(){
|
||||
parent.location.reload();
|
||||
}, 500);
|
||||
}else{
|
||||
leyer.msg("修改失败");
|
||||
}
|
||||
|
||||
//parent.layer.msg('您将标记 [ sdf ] 成功传送给了父窗口');
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,3 +1,119 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||
pageEncoding="UTF-8"%>
|
||||
rulelist.html
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>规则列表</title>
|
||||
<link rel="stylesheet" href="../public/layui/css/layui.css" media="all">
|
||||
<style>
|
||||
.layui-table,.layui-table-view{
|
||||
margin: 0 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<!-- 表单 -->
|
||||
<table class="layui-hide" id="ruleTable" lay-filter="formFilter"></table>
|
||||
<script src="../public/layui/layui.js" charset="utf-8"></script>
|
||||
<!-- 头部工具栏 -->
|
||||
<script type="text/html" id="headBar">
|
||||
<button type="button" class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon">添加</i></button>
|
||||
</script>
|
||||
|
||||
<!-- 表格后面的操作 -->
|
||||
<script type="text/html" id="operateBar">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
||||
</script>
|
||||
<script>
|
||||
layui.use(['table','jquery'], function(){
|
||||
$ = layui.jquery;
|
||||
var table = layui.table;
|
||||
// 进行渲染
|
||||
var tableIns = table.render({
|
||||
elem: '#ruleTable'
|
||||
,url:'./ruleList'
|
||||
,toolbar: '#headBar'
|
||||
,height: '600'
|
||||
,cols: [[
|
||||
{fixed: 'left',field:'id', width:140, title: 'ID', sort: true}
|
||||
,{field:'limit_day', width:180, title: '限制天数', sort: true}
|
||||
,{field:'borrow_num', width:180, title: '限制本数', sort: true}
|
||||
,{field:'borrow_library', width:180, title: '限制图书馆'}
|
||||
,{field:'overtime_fee', title: '逾期每天费用', width: 150}
|
||||
,{fixed: 'right', title:'操作', toolbar: '#operateBar', align: 'center', width:150}
|
||||
]]
|
||||
});
|
||||
|
||||
// 头部工具栏事件
|
||||
table.on('toolbar(formFilter)', function(obj){
|
||||
var checkStatus = table.checkStatus(obj.config.id);
|
||||
switch(obj.event){
|
||||
// 添加规则
|
||||
case 'add':
|
||||
var addCardLayer = layer.open({
|
||||
type: 2,
|
||||
title: '添加规则',
|
||||
area: ['800px', '500px'],
|
||||
maxmin: true,
|
||||
content: 'ruleadd.jsp',
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
// 侧边工具栏事件
|
||||
table.on(('tool(formFilter)'), function(obj){
|
||||
var data = obj.data;
|
||||
var layEvent = obj.event;
|
||||
var tr = obj.tr;
|
||||
var id = data.id;
|
||||
switch(obj.event){
|
||||
case 'edit':
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '更改信息',
|
||||
area: ['800px', '600px'],
|
||||
maxmin: true,
|
||||
shadeClose: true,
|
||||
content: 'ruleedit.jsp?id=' +id,
|
||||
})
|
||||
break;
|
||||
case 'del':
|
||||
layer.confirm("确认要删除么,非必要请勿删除",function(){
|
||||
$.ajax({
|
||||
url: './ruleDel',
|
||||
data: "id=" +id,
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
timout: 3000,
|
||||
success: function(data){
|
||||
if(data.code == 0){
|
||||
layer.msg(data.msg,{
|
||||
icon: 6,
|
||||
anim: 5,
|
||||
time: 500
|
||||
})
|
||||
setTimeout(function(){
|
||||
parent.location.reload();
|
||||
}, 500)
|
||||
|
||||
}else{
|
||||
layer.msg(data.msg,{
|
||||
icon:5,
|
||||
anim:6
|
||||
})
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
layer.msg("连接超时");
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,48 @@
|
||||
package javabean;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
public class TestConnection {
|
||||
public static void main(String[] args) throws ClassNotFoundException, SQLException {
|
||||
// 获取rule
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet resultSet = null;
|
||||
int result = 0;
|
||||
String password = "1234";
|
||||
String reader = "1234";
|
||||
String rule_id = "1";
|
||||
String status = "1";
|
||||
connection = (Connection) Base.getConnection();
|
||||
String sql = "insert into borrow_card(password, reader, rule_id, status) values(?,?,?,?)";
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setString(1, password);
|
||||
pstmt.setString(2, reader);
|
||||
pstmt.setString(3, rule_id);
|
||||
pstmt.setString(4, status);
|
||||
result = pstmt.executeUpdate();
|
||||
System.out.println(result);
|
||||
//获取id
|
||||
//connection1= (Connection) Base.getConnection();
|
||||
String findIdSql = "select id from borrow_card where password=? and reader=? and rule_id=? and status=? limit 1";
|
||||
pstmt = connection.prepareStatement(findIdSql);
|
||||
pstmt.setString(1, password);
|
||||
pstmt.setString(2, reader);
|
||||
pstmt.setString(3, rule_id);
|
||||
pstmt.setString(4, status);
|
||||
// pstmt1 = connection.prepareStatement(findIdSql);
|
||||
// pstmt1.setString(1, password);
|
||||
// pstmt1.setString(2, reader);
|
||||
// pstmt1.setString(3, rule_id);
|
||||
// pstmt1.setString(4, status);
|
||||
resultSet = pstmt.executeQuery();
|
||||
while(resultSet.next()) {
|
||||
System.out.println(resultSet.getString("id"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Servlet implementation class ServletExample
|
||||
*/
|
||||
|
||||
public class ServletExample extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ServletExample() {
|
||||
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
response.getWriter().append("Served at: ").append(request.getContextPath());
|
||||
}
|
||||
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
doGet(request, response);
|
||||
}
|
||||
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Servlet implementation class Test
|
||||
*/
|
||||
|
||||
public class Test extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public Test() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
|
||||
* response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
response.getWriter().append("Served at:ddd ").append(request.getContextPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
|
||||
* response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
// TODO Auto-generated method stub
|
||||
doGet(request, response);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
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.sql.Connection;
|
||||
|
||||
import javabean.Base;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Servlet implementation class BookAdd
|
||||
*/
|
||||
@WebServlet("/admin/bookAdd")
|
||||
public class BookAdd extends HttpServlet {
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("application/json; charset=utf8");
|
||||
String name = req.getParameter("name");
|
||||
String author = req.getParameter("author");
|
||||
String library_id = req.getParameter("library_id");
|
||||
String sort_id = req.getParameter("sort_id");
|
||||
String position = req.getParameter("position");
|
||||
String status = req.getParameter("status");
|
||||
String description = req.getParameter("description");
|
||||
System.out.println(description+"-------------"); //debug
|
||||
JSONObject json = new JSONObject();
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
//ResultSet resultSet = null;
|
||||
int result = 0;
|
||||
String sql = "insert into books(name, author, library_id, sort_id, position, status, description) values(?,?,?,?,?,?,?)";
|
||||
System.out.println(sql);
|
||||
PrintWriter out = resp.getWriter();
|
||||
try {
|
||||
connection = (Connection) Base.getConnection();
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setString(1, name);
|
||||
pstmt.setString(2, author);
|
||||
pstmt.setString(3, library_id);
|
||||
pstmt.setString(4, sort_id);
|
||||
pstmt.setString(5, position);
|
||||
pstmt.setString(6, status);
|
||||
pstmt.setString(7, description);
|
||||
result = pstmt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
Base.closeResource(connection, pstmt, null);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(result==1) {
|
||||
json.put("code", "0");
|
||||
json.put("msg", "success");
|
||||
}else {
|
||||
json.put("code", "1");
|
||||
json.put("msg", "error");
|
||||
}
|
||||
out.write(json.toString());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
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 javabean.JDBCBean;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
|
||||
@WebServlet("/admin/bookDel")
|
||||
public class BookDel extends HttpServlet {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("application/json; charset=utf8");
|
||||
String id = req.getParameter("id");
|
||||
JSONObject json = new JSONObject();
|
||||
JDBCBean db = new JDBCBean();
|
||||
String sql = "delete from books where id = " +id;
|
||||
int result = 0;
|
||||
int code = 1;
|
||||
String msg = "";
|
||||
if( id != null && !id.equals("") ) {
|
||||
result = db.executeUpdate(sql);
|
||||
}
|
||||
if( result == 1 ) {
|
||||
code = 0;
|
||||
msg = "删除成功";
|
||||
}else {
|
||||
code = 1;
|
||||
msg = "删除失败";
|
||||
}
|
||||
json.put("code", code);
|
||||
json.put("msg", msg);
|
||||
db.close();
|
||||
PrintWriter out = resp.getWriter();
|
||||
out.print( json.toString() );
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
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.sql.Connection;
|
||||
|
||||
import javabean.Base;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
|
||||
@WebServlet("/admin/bookEdit")
|
||||
public class BookEdit extends HttpServlet {
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("application/json; charset=utf8");
|
||||
String id = req.getParameter("id");
|
||||
String name = req.getParameter("name");
|
||||
String author = req.getParameter("author");
|
||||
String library_id = req.getParameter("library_id");
|
||||
String sort_id = req.getParameter("sort_id");
|
||||
String position = req.getParameter("position");
|
||||
String status = req.getParameter("status");
|
||||
String description = req.getParameter("description");
|
||||
System.out.println(description+"-------------");
|
||||
JSONObject json = new JSONObject();
|
||||
//if(id == null || id.equals(""))
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
//ResultSet resultSet = null;
|
||||
int result = 0;
|
||||
String sql = "update books set name=? ,author=? ,library_id=? ,sort_id=? ,position=? ,status=?, description=? where id=?";
|
||||
PrintWriter out = resp.getWriter();
|
||||
try {
|
||||
connection = (Connection) Base.getConnection();
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setString(1, name);
|
||||
pstmt.setString(2, author);
|
||||
pstmt.setString(3, library_id);
|
||||
pstmt.setString(4, sort_id);
|
||||
pstmt.setString(5, position);
|
||||
pstmt.setString(6, status);
|
||||
pstmt.setString(7, description);
|
||||
pstmt.setString(8, id);
|
||||
result = pstmt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
Base.closeResource(connection, pstmt, null);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(result==1) {
|
||||
json.put("code", "0");
|
||||
json.put("msg", "success");
|
||||
}else {
|
||||
json.put("code", "1");
|
||||
json.put("msg", "error");
|
||||
}
|
||||
out.write(json.toString());
|
||||
|
||||
|
||||
|
||||
|
||||
//System.out.println(postData);
|
||||
//JSONObject json = JSONObject.fromObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
doPost(req, resp);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
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.sql.Connection;
|
||||
|
||||
import javabean.Base;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
|
||||
@WebServlet("/admin/borrowList")
|
||||
public class BorrowList extends HttpServlet {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("application/json; charset=utf8");
|
||||
// 接收参数
|
||||
String limit = req.getParameter("limit");
|
||||
String page = req.getParameter("page");
|
||||
String condition = (String) req.getParameter("condition");
|
||||
String conditionValue = (String) req.getParameter("conditionValue");
|
||||
String where = ""; // 无限制条件
|
||||
if(page == null) {
|
||||
page = "1";
|
||||
}
|
||||
if(limit == null) {
|
||||
limit = "10";
|
||||
}
|
||||
// 准备查询
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
PreparedStatement countPstmt = null;
|
||||
ResultSet resultSet = null;
|
||||
ResultSet countSet = null;
|
||||
String sql = "";
|
||||
String countSql = "";
|
||||
// 准备返回参数
|
||||
int code = 1;
|
||||
String msg = "error";
|
||||
int count = 0;
|
||||
|
||||
JSONObject jsonData = new JSONObject();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
JSONObject jsonResult = new JSONObject();
|
||||
// 进行查询
|
||||
try {
|
||||
connection = (Connection) Base.getConnection();
|
||||
sql = "select id, card_id, book_id, "
|
||||
+ "DATE_FORMAT(borrow_date, '%Y-%m-%d %k:%i:%s') as borrow_date, "
|
||||
+ "DATE_FORMAT(return_date, '%Y-%m-%d %k:%i:%s') as return_date, "
|
||||
+ "DATE_FORMAT(end_date, '%Y-%m-%d %k:%i:%s') as end_date,"
|
||||
+ "illegal, manager_id "
|
||||
+ "from borrow_books";
|
||||
if(condition!=null && conditionValue != null && !condition.equals("") && !conditionValue.equals("")) {
|
||||
where = " where "+ condition +" like '%" +conditionValue +"%' ";
|
||||
sql += where;
|
||||
}else if(condition!=null && condition.equals("other")) {
|
||||
where = " where return_date is null and curtime()>end_date ";
|
||||
sql +=where;
|
||||
}
|
||||
sql += " limit ?,?";//1 10 (1-1)*10;
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setInt(1, (Integer.parseInt(page)-1) * Integer.parseInt(limit));
|
||||
pstmt.setInt(2, Integer.parseInt(limit));
|
||||
resultSet = pstmt.executeQuery();
|
||||
while(resultSet.next()) {
|
||||
jsonData.put("id", resultSet.getString("id"));
|
||||
jsonData.put("card_id", resultSet.getString("card_id"));
|
||||
jsonData.put("book_id", resultSet.getString("book_id"));
|
||||
jsonData.put("borrow_date", resultSet.getString("borrow_date"));
|
||||
jsonData.put("end_date", resultSet.getString("end_date"));
|
||||
jsonData.put("return_date", resultSet.getString("return_date"));
|
||||
jsonData.put("illegal", resultSet.getString("illegal"));
|
||||
jsonData.put("manager_id", resultSet.getString("manager_id"));
|
||||
jsonArray.add(jsonData);
|
||||
}
|
||||
countSql = "select count(*) as count from borrow_books ";
|
||||
countSql +=where;
|
||||
countPstmt = connection.prepareStatement(countSql);
|
||||
countSet = countPstmt.executeQuery();
|
||||
if(countSet.next()) {
|
||||
count = countSet.getInt("count");
|
||||
}
|
||||
if(!jsonArray.isEmpty()) {
|
||||
code = 0;
|
||||
msg = "查询成功";
|
||||
}else {
|
||||
code = 0;
|
||||
msg = "没有数据";
|
||||
}
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
msg = "class没找到";
|
||||
} catch (SQLException e) {
|
||||
msg = "sql错误";
|
||||
} finally {
|
||||
try {
|
||||
Base.closeResource(null, pstmt, resultSet);
|
||||
Base.closeResource(connection, countPstmt, countSet);
|
||||
} catch (SQLException e) {
|
||||
msg = "关闭资源失败";
|
||||
}
|
||||
|
||||
}
|
||||
// 返回数据
|
||||
jsonResult.put("code", code);
|
||||
jsonResult.put("count", count);
|
||||
jsonResult.put("msg", msg);
|
||||
jsonResult.put("data", jsonArray.toArray());
|
||||
PrintWriter out = resp.getWriter();
|
||||
out.print(jsonResult.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
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.sql.Connection;
|
||||
|
||||
import javabean.Base;
|
||||
import javabean.JDBCBean;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Servlet implementation class CardAdd
|
||||
*/
|
||||
@WebServlet("/admin/cardAdd")
|
||||
public class CardAdd extends HttpServlet {
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("application/json; charset=utf8");
|
||||
// 获取参数
|
||||
String reader = req.getParameter("reader");
|
||||
String password = req.getParameter("password");
|
||||
String rule_id = req.getParameter("rule_id");
|
||||
String status = req.getParameter("status");
|
||||
// 准备资源
|
||||
String code = "1";
|
||||
String msg = "error";
|
||||
String data = "";
|
||||
JSONObject json = new JSONObject();
|
||||
JSONObject jsonData = new JSONObject();
|
||||
Connection connection = null;
|
||||
Connection connection1 = null;
|
||||
PreparedStatement pstmt = null;
|
||||
PreparedStatement pstmt1 = null;
|
||||
String sql = null;
|
||||
int result = 0;
|
||||
ResultSet dataSet = null;
|
||||
// 参数不能为空
|
||||
if(reader == null || password == null || rule_id == null || rule_id == null || status == null) {
|
||||
code = "1";
|
||||
msg = "值不能为空";
|
||||
}else {
|
||||
try {
|
||||
connection = (Connection) Base.getConnection();
|
||||
sql = "insert into borrow_card(password, reader, rule_id, status) values(?,?,?,?)";
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setString(1, password);
|
||||
pstmt.setString(2, reader);
|
||||
pstmt.setString(3, rule_id);
|
||||
pstmt.setString(4, status);
|
||||
result = pstmt.executeUpdate();
|
||||
|
||||
//获取id
|
||||
connection1= (Connection) Base.getConnection();
|
||||
String findIdSql = "select id from borrow_card where password=? and reader=? and rule_id=? and status=? limit 1";
|
||||
pstmt1 = connection1.prepareStatement(findIdSql);
|
||||
pstmt1.setString(1, password);
|
||||
pstmt1.setString(2, reader);
|
||||
pstmt1.setString(3, rule_id);
|
||||
pstmt1.setString(4, status);
|
||||
dataSet = pstmt1.executeQuery();
|
||||
if(dataSet.next()) {
|
||||
jsonData.put("id", dataSet.getString("id"));
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
msg = "发生异常";
|
||||
} catch (SQLException e) {
|
||||
msg = "sql错误";
|
||||
System.out.println("sql失败");
|
||||
}
|
||||
try {
|
||||
Base.closeResource(connection, pstmt, null);
|
||||
Base.closeResource(connection1, pstmt1, dataSet);
|
||||
} catch (SQLException e) {
|
||||
msg = "关闭资源失败";
|
||||
}
|
||||
if(result == 1 && !jsonData.isNullObject() && !jsonData.isEmpty()) {
|
||||
System.out.println(jsonData.toString()); //debug
|
||||
code = "0";
|
||||
msg = "添加成功";
|
||||
}else {
|
||||
code = "1";
|
||||
msg = "执行失败";
|
||||
}
|
||||
}
|
||||
json.put("code", code);
|
||||
json.put("msg", msg);
|
||||
json.put("data", jsonData.toString());
|
||||
PrintWriter out = resp.getWriter();
|
||||
out.print(json.toString());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
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.sql.Connection;
|
||||
|
||||
import javabean.Base;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
@WebServlet("/admin/cardDel")
|
||||
public class CardDel extends HttpServlet {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("application/json; charset=utf8");
|
||||
// 接收数据
|
||||
String id = req.getParameter("id");
|
||||
// 处理数据
|
||||
Connection connection = null;
|
||||
PreparedStatement delCardPstmt = null;
|
||||
PreparedStatement delHistoryPstmt = null;
|
||||
String delCardSql = null;
|
||||
String delHistorySql = null;
|
||||
int delCardResult = 0;
|
||||
int delHistoryResult = 0;
|
||||
// 返回数据
|
||||
String code = "1";
|
||||
String msg = "error";
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONObject jsonData = new JSONObject();
|
||||
// 开始处理
|
||||
if(id != null && !id.equals("")) {
|
||||
try {
|
||||
// 公共连接
|
||||
connection = (Connection) Base.getConnection();
|
||||
// 删除借书记录
|
||||
delHistorySql = "delete from borrow_books where card_id=?";
|
||||
delHistoryPstmt = connection.prepareStatement(delHistorySql);
|
||||
delHistoryPstmt.setString(1, id);
|
||||
delHistoryResult = delHistoryPstmt.executeUpdate();
|
||||
// 返回删除记录条数
|
||||
jsonData.put("num", delHistoryResult);
|
||||
// 删除阅读证
|
||||
delCardSql = "delete from borrow_card where id=? limit 1";
|
||||
delCardPstmt = connection.prepareStatement(delCardSql);
|
||||
delCardPstmt.setString(1, id);
|
||||
delCardResult = delCardPstmt.executeUpdate();
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
msg = "连接失败";
|
||||
} catch (SQLException e) {
|
||||
msg = "sql错误";
|
||||
} finally {
|
||||
try {
|
||||
delCardPstmt.close();
|
||||
Base.closeResource(connection, delCardPstmt, null);
|
||||
} catch (SQLException e) {
|
||||
msg = "关闭失败";
|
||||
}
|
||||
}
|
||||
}
|
||||
PrintWriter out = resp.getWriter();
|
||||
if(delCardResult == 1) {
|
||||
code = "0";
|
||||
msg = "删除借阅证成功";
|
||||
}
|
||||
jsonObject.put("code", code);
|
||||
jsonObject.put("msg", msg);
|
||||
jsonObject.put("data", jsonData);
|
||||
out.print(jsonObject.toString());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
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.sql.Connection;
|
||||
|
||||
import javabean.Base;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
|
||||
@WebServlet("/admin/cardEdit")
|
||||
public class CardEdit extends HttpServlet {
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("application/json; charset=utf8");
|
||||
// 接受数据
|
||||
String id = req.getParameter("id");
|
||||
String password = req.getParameter("password");
|
||||
String reader = req.getParameter("reader");
|
||||
String rule_id = req.getParameter("rule_id");
|
||||
String status = req.getParameter("status");
|
||||
// 准备资源
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet resultSet = null;
|
||||
int result = 0;
|
||||
String sql = null;
|
||||
// 返回数据
|
||||
String code = "1";
|
||||
String msg = "error";
|
||||
JSONObject json = new JSONObject();
|
||||
PrintWriter out = resp.getWriter();
|
||||
// 判断数据
|
||||
if(id == null || password == null || reader == null || reader == null || status == null ||
|
||||
id.equals("") || password.equals("") || reader.equals("") || rule_id.equals("") || status.equals("")) {
|
||||
code = "1";
|
||||
msg = "参数不能为空";
|
||||
}else {
|
||||
sql = "update borrow_card set password=?, reader=?, rule_id=?, status=? where id=?";
|
||||
try {
|
||||
connection = (Connection) Base.getConnection();
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setString(1, password);
|
||||
pstmt.setString(2, reader);
|
||||
pstmt.setString(3, rule_id);
|
||||
pstmt.setString(4, status);
|
||||
pstmt.setString(5, id);
|
||||
result = pstmt.executeUpdate();
|
||||
} catch (ClassNotFoundException e1) {
|
||||
msg = "错误";
|
||||
} catch (SQLException e) {
|
||||
msg = "sql错误";
|
||||
} finally {
|
||||
try {
|
||||
Base.closeResource(connection, pstmt, resultSet);
|
||||
} catch (SQLException e) {
|
||||
msg = "关闭失败";
|
||||
}
|
||||
}
|
||||
if(result == 1) {
|
||||
code = "0";
|
||||
msg = "修改成功";
|
||||
}
|
||||
json.put("code", code);
|
||||
json.put("msg", msg);
|
||||
out.print(json.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
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.sql.Connection;
|
||||
|
||||
import javabean.Base;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Servlet implementation class CardList
|
||||
*/
|
||||
@WebServlet("/admin/cardList")
|
||||
public class CardList extends HttpServlet {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("application/json; charset:utf8");
|
||||
// 接收参数
|
||||
String limit = req.getParameter("limit");
|
||||
String page = req.getParameter("page");
|
||||
String condition = (String) req.getParameter("condition");
|
||||
String conditionValue = (String) req.getParameter("conditionValue");
|
||||
String where = null; // 无限制条件
|
||||
if(page == null) {
|
||||
page = "1";
|
||||
}
|
||||
if(limit == null) {
|
||||
limit = "10";
|
||||
}
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet resultSet = null;
|
||||
int code = 1;
|
||||
String msg = "error";
|
||||
int count = 0;
|
||||
String sql = "";
|
||||
//String countSql = ""
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
JSONObject jsonResult = new JSONObject();
|
||||
try {
|
||||
// 获取数据
|
||||
connection = (Connection) Base.getConnection();
|
||||
sql = "select id,password,reader,rule_id,status from borrow_card";
|
||||
// where
|
||||
if(condition != null && conditionValue != null && !condition.isEmpty() && !conditionValue.isEmpty()) {
|
||||
where = " where "+ condition +" like '%" +conditionValue +"%'";
|
||||
sql = sql+where;
|
||||
}
|
||||
// 分页
|
||||
sql +=" order by id desc limit ?,?";
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
try {
|
||||
pstmt.setInt(1, (Integer.parseInt(page)-1) * Integer.parseInt(limit) );
|
||||
pstmt.setInt(2, Integer.parseInt(limit));
|
||||
} catch (NumberFormatException | SQLException e1) {
|
||||
}
|
||||
resultSet = pstmt.executeQuery();
|
||||
while(resultSet.next()) {
|
||||
jsonObject.put("id", resultSet.getString("id"));
|
||||
jsonObject.put("password", resultSet.getString("password"));
|
||||
jsonObject.put("reader", resultSet.getString("reader"));
|
||||
jsonObject.put("rule_id", resultSet.getString("rule_id"));
|
||||
jsonObject.put("status", resultSet.getString("status"));
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
// 获取总数
|
||||
sql = "select count(*) as count from borrow_card ";
|
||||
// 有限制
|
||||
if(where!=null) {
|
||||
sql = sql+where;
|
||||
}
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
resultSet = pstmt.executeQuery();
|
||||
if(resultSet.next()) {
|
||||
count = resultSet.getInt("count");
|
||||
}
|
||||
|
||||
if(!jsonArray.isEmpty()) {
|
||||
code = 0;
|
||||
msg = "成功";
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
msg = "没找到";
|
||||
e.printStackTrace();
|
||||
} catch (SQLException e) {
|
||||
msg = "sql错误";
|
||||
}finally {
|
||||
try {
|
||||
Base.closeResource(connection, pstmt, resultSet);
|
||||
} catch (SQLException e) {
|
||||
msg = "关闭失败";
|
||||
}
|
||||
}
|
||||
jsonResult.put("code", code);
|
||||
jsonResult.put("count", count);
|
||||
jsonResult.put("msg", msg);
|
||||
jsonResult.put("data", jsonArray.toString());
|
||||
PrintWriter out = resp.getWriter();
|
||||
out.print(jsonResult.toString());
|
||||
//out.print("{\"code\":0,\"msg\":\"\",\"count\":\"234\",\"data\":[{\"id\":\"1\",\"password\":\"23442\",\"reader\":\"minm\",\"rule_id\":\"1\",\"status\":\"2\"}]}");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
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.sql.Connection;
|
||||
|
||||
import javabean.Base;
|
||||
import javabean.Util;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
|
||||
@WebServlet("/admin/managerAdd")
|
||||
public class ManagerAdd extends HttpServlet {
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("application/json; charset=utf8");
|
||||
// 接收参数
|
||||
String name = req.getParameter("name");
|
||||
String account = req.getParameter("account");
|
||||
String password = req.getParameter("password");
|
||||
String email = req.getParameter("email");
|
||||
// 准备参数
|
||||
String sql = "";
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet resultSet = null;
|
||||
int result = 0;
|
||||
int count = 0;
|
||||
// 返回参数
|
||||
int code = 1;
|
||||
String msg = "";
|
||||
PrintWriter out = resp.getWriter();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
// 进行查询
|
||||
if(name==null || name.equals("") || account==null || account.equals("") || password==null || password.equals("") || email==null || email.equals("")) {
|
||||
msg = "参数不能为空";
|
||||
out.print(Util.jsonResponse(code, msg, null));
|
||||
}else {
|
||||
try {
|
||||
connection = (Connection) Base.getConnection();
|
||||
// 验证账号
|
||||
sql = "select count(*) as count from manager where account=?";
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setString(1, account);
|
||||
resultSet = pstmt.executeQuery();
|
||||
resultSet.next();
|
||||
count = resultSet.getInt("count");
|
||||
// 添加管理员
|
||||
if(count == 0) {
|
||||
sql = "insert into manager(name, account, password, email) values(?,?,?,?)";
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setString(1, name);
|
||||
pstmt.setString(2, account);
|
||||
pstmt.setString(3, password);
|
||||
pstmt.setString(4, email);
|
||||
result = pstmt.executeUpdate();
|
||||
}
|
||||
// 返回数据
|
||||
if(result == 1 && count == 0) {
|
||||
code = 0;
|
||||
msg = "添加成功";
|
||||
}else if(count > 0){
|
||||
msg = "账号重复";
|
||||
}else {
|
||||
msg = "添加失败";
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
msg = "class not found";
|
||||
} catch (SQLException e) {
|
||||
msg = "sql错误";
|
||||
} finally {
|
||||
try {
|
||||
Base.closeResource(connection, pstmt, resultSet);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
out.print(Util.jsonResponse(code, msg, null));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
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.sql.Connection;
|
||||
|
||||
import javabean.Base;
|
||||
import javabean.Util;
|
||||
|
||||
|
||||
@WebServlet("/admin/managerDel")
|
||||
public class ManagerDel extends HttpServlet {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
String id = req.getParameter("id");
|
||||
// 准备参数
|
||||
String sql = "";
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet resultSet = null;
|
||||
int result = 0;
|
||||
// 返回参数
|
||||
int code = 1;
|
||||
String msg = "";
|
||||
PrintWriter out = resp.getWriter();
|
||||
try {
|
||||
connection = (Connection) Base.getConnection();
|
||||
sql = "delete from manager where id=?";
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setString(1, id);
|
||||
result = pstmt.executeUpdate();
|
||||
if(result == 1) {
|
||||
code = 0;
|
||||
msg = "删除成功";
|
||||
}else {
|
||||
msg = "删除失败";
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
msg = "class not found";
|
||||
} catch (SQLException e) {
|
||||
msg = "sql错误";
|
||||
}
|
||||
out.print(Util.jsonResponse(code, msg, null));
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
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.sql.Connection;
|
||||
|
||||
import javabean.Base;
|
||||
import javabean.Util;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
|
||||
@WebServlet("/admin/managerEdit")
|
||||
public class ManagerEdit extends HttpServlet {
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("application/json; charset=utf8");
|
||||
// 接收参数
|
||||
String id = req.getParameter("id");
|
||||
String name = req.getParameter("name");
|
||||
String password = req.getParameter("password");
|
||||
String email = req.getParameter("email");
|
||||
// 准备参数
|
||||
String sql = "";
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet resultSet = null;
|
||||
int result = 0;
|
||||
// 返回参数
|
||||
int code = 1;
|
||||
String msg = "";
|
||||
PrintWriter out = resp.getWriter();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
// 进行查询
|
||||
if(name==null || name.equals("")|| password==null || password.equals("") || email==null || email.equals("")) {
|
||||
msg = "参数不能为空";
|
||||
out.print(Util.jsonResponse(code, msg, null));
|
||||
}else {
|
||||
try {
|
||||
connection = (Connection) Base.getConnection();
|
||||
// 添加管理员
|
||||
sql = "update manager set name=?, password=?, email=? where id=?";
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setString(1, name);
|
||||
pstmt.setString(2, password);
|
||||
pstmt.setString(3, email);
|
||||
pstmt.setString(4, id);
|
||||
result = pstmt.executeUpdate();
|
||||
|
||||
// 返回数据
|
||||
if(result == 1 ){
|
||||
code = 0;
|
||||
msg = "修改成功";
|
||||
}else {
|
||||
msg = "修改失败";
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
msg = "class not found";
|
||||
} catch (SQLException e) {
|
||||
msg = "sql错误";
|
||||
} finally {
|
||||
try {
|
||||
Base.closeResource(connection, pstmt, resultSet);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
out.print(Util.jsonResponse(code, msg, null));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
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.sql.Connection;
|
||||
|
||||
import javabean.Base;
|
||||
import javabean.Util;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
@WebServlet("/admin/managerList")
|
||||
public class ManagerList extends HttpServlet {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("application/json; charset=utf8");
|
||||
// 准备数据
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
String sql = "";
|
||||
ResultSet resultSet = null;
|
||||
// 返回数据
|
||||
int code = 1;
|
||||
String msg = "error";
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
PrintWriter out = resp.getWriter();
|
||||
try {
|
||||
connection = (Connection) Base.getConnection();
|
||||
sql = "select * from manager";
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
resultSet = pstmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
jsonObject.put("id", resultSet.getString("id"));
|
||||
jsonObject.put("name", resultSet.getString("name"));
|
||||
jsonObject.put("account", resultSet.getString("account"));
|
||||
jsonObject.put("password", resultSet.getString("password"));
|
||||
jsonObject.put("email", resultSet.getString("email"));
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
if (!jsonArray.isEmpty()) {
|
||||
code = 0;
|
||||
msg = "查询成功";
|
||||
} else {
|
||||
msg = "数据为空";
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
msg = "class找不到";
|
||||
} catch (SQLException e) {
|
||||
msg = "sql错误";
|
||||
}
|
||||
out.print(Util.jsonResponse(code, msg, jsonArray.toString()));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
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.sql.Connection;
|
||||
|
||||
import javabean.Base;
|
||||
import javabean.Common;
|
||||
import javabean.Util;
|
||||
|
||||
|
||||
@WebServlet("/admin/ruleAdd")
|
||||
public class RuleAdd extends HttpServlet {
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("application/json; charset=utf8");
|
||||
// 准备数据
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet resultSet = null;
|
||||
int result = 0;
|
||||
String sql = "";
|
||||
String borrow_library = "";
|
||||
|
||||
// 准备返回数据
|
||||
int code = 1;
|
||||
String msg = "";
|
||||
|
||||
// 获取数据
|
||||
// 获取限定图书馆1、2、3
|
||||
int num = 0;
|
||||
try {
|
||||
Map<String, String> libraryMap = Common.getLibraryMap();
|
||||
System.out.println(libraryMap);
|
||||
for(String key : libraryMap.keySet()) {
|
||||
if(req.getParameter("borrow_library[" +key +"]") != null) {
|
||||
if(num == 0) {
|
||||
borrow_library += key;
|
||||
num++;
|
||||
}else {
|
||||
borrow_library += "、"+key;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(borrow_library.isEmpty()) {
|
||||
msg = "允许图书馆不能为空";
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
msg = "获取图书馆失败";
|
||||
}
|
||||
String borrow_num = req.getParameter("borrow_num");
|
||||
String limit_day = req.getParameter("limit_day");
|
||||
String overtime_fee = req.getParameter("overtime_fee");
|
||||
try {
|
||||
connection = (Connection) Base.getConnection();
|
||||
sql = "insert into rules(borrow_num, limit_day, borrow_library, overtime_fee) values(?,?,?,?)";
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setString(1, borrow_num);
|
||||
pstmt.setString(2, limit_day);
|
||||
pstmt.setString(3, borrow_library);
|
||||
pstmt.setString(4, overtime_fee);
|
||||
result = pstmt.executeUpdate();
|
||||
if(result == 1) {
|
||||
code = 0;
|
||||
msg = "success";
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
msg = "classnotfound";
|
||||
} catch (SQLException e) {
|
||||
msg = "SQL错误";
|
||||
} finally {
|
||||
try {
|
||||
Base.closeResource(connection, pstmt, null);
|
||||
} catch (SQLException e) {
|
||||
msg = "关闭失败";
|
||||
}
|
||||
}
|
||||
|
||||
PrintWriter out = resp.getWriter();
|
||||
out.print(Util.jsonResponse(code, msg, null));
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
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.sql.Connection;
|
||||
|
||||
import javabean.Base;
|
||||
import javabean.Util;
|
||||
|
||||
|
||||
@WebServlet("/admin/ruleDel")
|
||||
public class RuleDel extends HttpServlet {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("application/json; charset=utf8");
|
||||
// 接受数据
|
||||
String id = req.getParameter("id");
|
||||
// 准备数据
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet resultSet = null;
|
||||
int result = 0;
|
||||
String sql = "";
|
||||
// 返回数据
|
||||
int code = 1;
|
||||
String msg = "error";
|
||||
PrintWriter out = resp.getWriter();
|
||||
// 进行查询
|
||||
try {
|
||||
connection = (Connection) Base.getConnection();
|
||||
sql = "delete from rules where id = ?";
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setString(1, id);
|
||||
result = pstmt.executeUpdate();
|
||||
if(result == 1) {
|
||||
code = 0;
|
||||
msg = "删除成功";
|
||||
}else {
|
||||
msg = "删除失败";
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
msg = "class没找到";
|
||||
} catch (SQLException e) {
|
||||
msg = "sql错误";
|
||||
}
|
||||
out.print(Util.jsonResponse(code, msg, null));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
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.sql.Connection;
|
||||
|
||||
import javabean.Base;
|
||||
import javabean.Common;
|
||||
import javabean.Util;
|
||||
|
||||
/**
|
||||
* Servlet implementation class RuleEdit
|
||||
*/
|
||||
@WebServlet("/admin/ruleEdit")
|
||||
public class RuleEdit extends HttpServlet {
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("application/json; charset=utf8");
|
||||
// 准备数据
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet resultSet = null;
|
||||
int result = 0;
|
||||
String sql = "";
|
||||
String borrow_library = "";
|
||||
|
||||
// 准备返回数据
|
||||
int code = 1;
|
||||
String msg = "";
|
||||
|
||||
// 获取数据
|
||||
// 获取限定图书馆1、2、3
|
||||
int num = 0;
|
||||
try {
|
||||
Map<String, String> libraryMap = Common.getLibraryMap();
|
||||
System.out.println(libraryMap);
|
||||
for(String key : libraryMap.keySet()) {
|
||||
if(req.getParameter("borrow_library[" +key +"]") != null) {
|
||||
if(num == 0) {
|
||||
borrow_library += key;
|
||||
num++;
|
||||
}else {
|
||||
borrow_library += "、"+key;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(borrow_library.isEmpty()) {
|
||||
msg = "允许图书馆不能为空";
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
msg = "获取图书馆失败";
|
||||
}
|
||||
String borrow_num = req.getParameter("borrow_num");
|
||||
String limit_day = req.getParameter("limit_day");
|
||||
String overtime_fee = req.getParameter("overtime_fee");
|
||||
String id = req.getParameter("id");
|
||||
try {
|
||||
connection = (Connection) Base.getConnection();
|
||||
sql = "update rules set borrow_num=?, limit_day=?, borrow_library=?,overtime_fee=? where id=?";
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
pstmt.setString(1, borrow_num);
|
||||
pstmt.setString(2, limit_day);
|
||||
pstmt.setString(3, borrow_library);
|
||||
pstmt.setString(4, overtime_fee);
|
||||
pstmt.setString(5, id);
|
||||
result = pstmt.executeUpdate();
|
||||
if(result == 1) {
|
||||
code = 0;
|
||||
msg = "success";
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
msg = "classnotfound";
|
||||
} catch (SQLException e) {
|
||||
msg = "SQL错误";
|
||||
} finally {
|
||||
try {
|
||||
Base.closeResource(connection, pstmt, null);
|
||||
} catch (SQLException e) {
|
||||
msg = "关闭失败";
|
||||
}
|
||||
}
|
||||
|
||||
PrintWriter out = resp.getWriter();
|
||||
out.print(Util.jsonResponse(code, msg, null));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package servlet.admin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
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.sql.Connection;
|
||||
|
||||
import javabean.Base;
|
||||
import javabean.Util;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
|
||||
@WebServlet("/admin/ruleList")
|
||||
public class RuleList extends HttpServlet {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.setContentType("application/json; charset=utf8");
|
||||
// 准备查询
|
||||
Connection connection = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet resultSet = null;
|
||||
String sql = "";
|
||||
// 准备返回参数
|
||||
int code = 1;
|
||||
String msg = "error";
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
try {
|
||||
connection = (Connection) Base.getConnection();
|
||||
sql = "select * from rules";
|
||||
pstmt = connection.prepareStatement(sql);
|
||||
resultSet = pstmt.executeQuery();
|
||||
while(resultSet.next()) {
|
||||
jsonObject.put("id", resultSet.getString("id"));
|
||||
jsonObject.put("limit_day", resultSet.getString("limit_day"));
|
||||
jsonObject.put("borrow_num", resultSet.getString("borrow_num"));
|
||||
jsonObject.put("borrow_library", resultSet.getString("borrow_library"));
|
||||
jsonObject.put("overtime_fee", resultSet.getString("overtime_fee"));
|
||||
jsonArray.add(jsonObject);
|
||||
}
|
||||
code = 0;
|
||||
if(!jsonArray.isEmpty()) {
|
||||
msg = "查询成功";
|
||||
}else {
|
||||
msg = "没有数据";
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
msg = "sql错误";
|
||||
} catch (ClassNotFoundException e) {
|
||||
msg = "class没找到";
|
||||
} finally {
|
||||
try {
|
||||
Base.closeResource(connection, pstmt, resultSet);
|
||||
} catch (SQLException e) {
|
||||
msg = "关闭失败";
|
||||
}
|
||||
}
|
||||
|
||||
PrintWriter out = resp.getWriter();
|
||||
out.print( Util.jsonResponse(code, msg, jsonArray.toString()) );
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue