diff --git a/WebContent/admin/bookadd.jsp b/WebContent/admin/bookadd.jsp index 85f42ed..14bd18f 100644 --- a/WebContent/admin/bookadd.jsp +++ b/WebContent/admin/bookadd.jsp @@ -123,9 +123,13 @@ layui.use(['form', 'layedit', 'jquery'], function(){ dataType: 'JSON', success: function(data){ if(data.code == "0"){ - parent.layer.msg("添加成功"); - var index = parent.layer.getFrameIndex(window.name); - parent.layer.close(index); + parent.layer.msg("添加成功",{ + icon: 6, + time: 500 + }); + setTimeout(function(){ + parent.location.reload(); + }, 500); }else{ leyer.msg("添加失败"); } diff --git a/WebContent/admin/bookedit.jsp b/WebContent/admin/bookedit.jsp index 3ffcddd..a8406f3 100644 --- a/WebContent/admin/bookedit.jsp +++ b/WebContent/admin/bookedit.jsp @@ -15,7 +15,6 @@ @@ -152,17 +151,21 @@ layui.use(['form', 'layedit', 'jquery'], function(){ url: './bookEdit', method: 'post', data: data.field, //JSON.stringify(data.field), - dataType: 'JSON', + dataType: 'json', success: function(data){ if(data.code == "0"){ - parent.layer.msg("修改成功"); - var index = parent.layer.getFrameIndex(window.name); - parent.layer.close(index); + parent.layer.msg("修改成功",{ + icon: 6, + time: 1000 + }); + setTimeout(function(){ + parent.location.reload() + }, 1000); + //var index = parent.layer.getFrameIndex(window.name); //操作父页面 + //parent.layer.close(index); }else{ leyer.msg("修改失败"); } - - //parent.layer.msg('您将标记 [ sdf ] 成功传送给了父窗口'); } }) diff --git a/WebContent/admin/booklist.jsp b/WebContent/admin/booklist.jsp index 6aed64a..780766a 100644 --- a/WebContent/admin/booklist.jsp +++ b/WebContent/admin/booklist.jsp @@ -13,7 +13,6 @@ - + + +
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+
+ + +
+
+
+ + + + \ No newline at end of file diff --git a/WebContent/admin/cardedit.jsp b/WebContent/admin/cardedit.jsp new file mode 100644 index 0000000..8ddd019 --- /dev/null +++ b/WebContent/admin/cardedit.jsp @@ -0,0 +1,93 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +图书证修改 + + + + + +
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + + +
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+
+ +
+ +
+
+ +
+
+ + + +
+
+
+ + + + \ No newline at end of file diff --git a/WebContent/admin/cardlist.jsp b/WebContent/admin/cardlist.jsp index b8639f2..4c6ba15 100644 --- a/WebContent/admin/cardlist.jsp +++ b/WebContent/admin/cardlist.jsp @@ -4,9 +4,123 @@ - + 借阅卡 + + + - card + +
+ + + + + + + \ No newline at end of file diff --git a/WebContent/admin/data.json b/WebContent/admin/data.json index 845c588..fae61cf 100644 --- a/WebContent/admin/data.json +++ b/WebContent/admin/data.json @@ -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"}]} \ No newline at end of file +{"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}]} \ No newline at end of file diff --git a/WebContent/reader/02readerNav.jsp b/WebContent/reader/02readerNav.jsp index 66546e3..fc0c054 100644 --- a/WebContent/reader/02readerNav.jsp +++ b/WebContent/reader/02readerNav.jsp @@ -40,7 +40,7 @@ <%}else{%>
  • 登录
  • <%} - %>s + %> diff --git a/build/classes/filter/AdminFilter.class b/build/classes/filter/AdminFilter.class index fdfb5a8..5262c53 100644 Binary files a/build/classes/filter/AdminFilter.class and b/build/classes/filter/AdminFilter.class differ diff --git a/build/classes/javabean/Admin.class b/build/classes/javabean/Admin.class index b834a89..cd4bf25 100644 Binary files a/build/classes/javabean/Admin.class and b/build/classes/javabean/Admin.class differ diff --git a/src/filter/AdminFilter.java b/src/filter/AdminFilter.java index 624c6af..584b67a 100644 --- a/src/filter/AdminFilter.java +++ b/src/filter/AdminFilter.java @@ -1,6 +1,8 @@ package filter; import java.io.IOException; +import java.io.PrintWriter; + import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -18,17 +20,14 @@ import javax.servlet.http.HttpSession; */ public class AdminFilter implements Filter { - public void destroy() { - - } - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - //TODO HttpServletRequest req = (HttpServletRequest) request; HttpSession session = req.getSession(); if(session == null || session.getAttribute("admin") == null) { HttpServletResponse rep = (HttpServletResponse)response; - rep.sendRedirect(req.getContextPath() +"/adminLogin.html"); + PrintWriter out =response.getWriter(); + // iframe父页面直接跳转到登录界面 + out.print(""); } chain.doFilter(request, response); } diff --git a/src/javabean/Admin.java b/src/javabean/Admin.java index b58052a..2dfe606 100644 --- a/src/javabean/Admin.java +++ b/src/javabean/Admin.java @@ -74,8 +74,8 @@ public class Admin { whereString += " where "+where.get("condition") +" like '%" +where.get("conditionValue") +"%' "; sql += whereString; } - sql += " limit ?,? "; - System.out.println("sql: " +sql); + sql += "order by id desc limit ?,? "; + //System.out.println("sql: " +sql); debug pstmt = (PreparedStatement) connection.prepareStatement(sql); pstmt.setInt(1, (number-1) * size ); pstmt.setInt(2, size); diff --git a/src/servlet/admin/CardAdd.java b/src/servlet/admin/CardAdd.java new file mode 100644 index 0000000..78d862b --- /dev/null +++ b/src/servlet/admin/CardAdd.java @@ -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()); + } + +}