From b9ac28edda0dbede649519d477f1b840a9992174 Mon Sep 17 00:00:00 2001 From: you <284908631@qq.com> Date: Sat, 6 Jun 2020 00:56:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E4=BD=93=E5=AE=8C=E6=88=90=E5=80=9F?= =?UTF-8?q?=E9=98=85=E8=AF=81=E7=9A=84=E6=B7=BB=E5=8A=A0=EF=BC=8C=E5=8F=91?= =?UTF-8?q?=E7=8E=B0=E9=94=99=E8=AF=AF=EF=BC=9A=E5=90=8C=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=9F=A5=E8=AF=A2=E4=B8=8D=E5=90=8C=E7=9A=84?= =?UTF-8?q?=E8=AF=AD=E5=8F=A5=E4=BC=9A=E5=A4=B1=E8=B4=A5=EF=BC=9F=EF=BC=9F?= =?UTF-8?q?=EF=BC=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebContent/admin/bookadd.jsp | 10 ++- WebContent/admin/bookedit.jsp | 17 ++-- WebContent/admin/booklist.jsp | 21 +---- WebContent/admin/cardadd.jsp | 93 +++++++++++++++++++ WebContent/admin/cardedit.jsp | 93 +++++++++++++++++++ WebContent/admin/cardlist.jsp | 118 ++++++++++++++++++++++++- WebContent/admin/data.json | 2 +- WebContent/reader/02readerNav.jsp | 2 +- build/classes/filter/AdminFilter.class | Bin 1937 -> 1993 bytes build/classes/javabean/Admin.class | Bin 5493 -> 5471 bytes src/filter/AdminFilter.java | 11 ++- src/javabean/Admin.java | 4 +- src/servlet/admin/CardAdd.java | 102 +++++++++++++++++++++ 13 files changed, 433 insertions(+), 40 deletions(-) create mode 100644 WebContent/admin/cardadd.jsp create mode 100644 WebContent/admin/cardedit.jsp create mode 100644 src/servlet/admin/CardAdd.java 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 fdfb5a8def9d78b6711d9c89d8bd459f114203fc..5262c532f40f4acbf4b652e77bb5cb9250271837 100644 GIT binary patch delta 808 zcmZvaTTc@~6vzLwmu_iS3x!g)KrLWz(2FR7l#5psw8~AXC|;UU%PMr6x`K%h_z`U8 z1NiKdF(#O5Vn|Fh%8PstW8#C48qbz$crcU9naP~_pWpw?R9v53jxWF8z6UUfyA{XF z%7^vN7KY~g+4XEvHCL_vZ-5qudtju6M_!(3S}nd2LJaoN~Nl(OY~(M+rw zxva&VSSjc4jfEYEPw0Y z7SL7Wp4;Q8a}yaZAzky5!DY%6ELu!shIDP1r7=eyT$sc>u9Dx-ApN9kBxfV(0Ht21 yH(sPmDuiDMDDWx>#7Xc5Zq^$j(ayuuia#8zA+*+tuzv^)OSnZj47W)~z@0w|lA6%~ delta 791 zcmZXS-%b-z5XQgR?w{JOR!gB>fl@%0{-vm`+ExWo5wubZilSH5uC=7JNhw6H`UED{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af..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()); + } + +}