parent
4a89dccb98
commit
b9ac28edda
@ -0,0 +1,93 @@
|
||||
<%@ 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>
|
||||
<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">
|
||||
<option value=""></option>
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="2">3</option>
|
||||
<option value="3">音乐</option>
|
||||
<option value="4">旅行</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.msg(data.data["id"],{
|
||||
icon: 6,
|
||||
time: 5500
|
||||
});
|
||||
/*setTimeout(function(){
|
||||
parent.location.reload();
|
||||
}, 500);*/
|
||||
}else{
|
||||
leyer.msg("添加失败");
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
})
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,93 @@
|
||||
<%@ 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>
|
||||
<form class="layui-form layui-form-pane" action="" lay-filter="example">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">姓名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="username" lay-verify="title" 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">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">选择框</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="interest" lay-filter="aihao">
|
||||
<option value=""></option>
|
||||
<option value="0">写作</option>
|
||||
<option value="1">阅读</option>
|
||||
<option value="2">游戏</option>
|
||||
<option value="3">音乐</option>
|
||||
<option value="4">旅行</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">复选框</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="like[write]" title="写作">
|
||||
<input type="checkbox" name="like[read]" title="阅读">
|
||||
<input type="checkbox" name="like[daze]" title="发呆">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">开关</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="close" lay-skin="switch" lay-text="ON|OFF">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">单选框</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="sex" value="男" title="男" checked="">
|
||||
<input type="radio" name="sex" value="女" title="女">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">文本域</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea placeholder="请输入内容" class="layui-textarea" name="desc"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button type="button" class="layui-btn layui-btn-normal" id="LAY-component-form-setval">赋值</button>
|
||||
<button type="button" class="layui-btn layui-btn-normal" id="LAY-component-form-getval">取值</button>
|
||||
<button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
layui.use(['form'], function(){
|
||||
var form = layui.form
|
||||
,layer = layui.layer;
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
</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":"","count":1000,"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}]}
|
Binary file not shown.
Binary file not shown.
@ -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 com.mysql.jdbc.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()) {
|
||||
System.out.println(jsonData.toString()); //debug
|
||||
code = "0";
|
||||
msg = "添加成功";
|
||||
}else {
|
||||
code = "1";
|
||||
}
|
||||
}
|
||||
json.put("code", code);
|
||||
json.put("msg", msg);
|
||||
json.put("data", jsonData.toString());
|
||||
PrintWriter out = resp.getWriter();
|
||||
//out.print("{\"code\": 0,\"msg\": \"success\"}");
|
||||
out.print(json.toString());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue