diff --git a/Cart.java b/Cart.java deleted file mode 100644 index 259eea4..0000000 --- a/Cart.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.itbaizhan.util; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import com.itbaizhan.orm.Tgoods; -import com.itbaizhan.orm.TorderItem; - -public class Cart { - - // 购物车属性 - // 使用一个 Map 存储购物项,Map 的 key 是商品的 id,value 是购物项 TorderItem - protected Map items; - - /** - * 构造函数,初始化购物车。 - * 如果购物车的 items 为 null,创建一个新的 HashMap 实例。 - */ - public Cart() { - if (items == null) { - items = new HashMap(); // 初始化购物车,使用 HashMap 存储购物项 - } - } - - /** - * 将商品添加到购物车中。 - * 如果购物车中已经存在该商品,则增加该商品的数量;如果不存在,则新建购物项并添加。 - * - * @param goodsId 商品的 ID - * @param orderItem 购物项,即商品的详细信息,包括数量等 - */ - public void addGoods(String goodsId, TorderItem orderItem) { - // 判断购物车中是否已经存在该商品 - if (items.containsKey(goodsId)) { // 如果购物车中已存在该商品 - // 获取原有的购物项,更新商品的数量 - TorderItem _orderItem = items.get(goodsId); // 获取购物车中原有的购物项 - _orderItem.setGoods_quantity(_orderItem.getGoods_quantity() + orderItem.getGoods_quantity()); // 更新数量 - items.put(goodsId, _orderItem); // 更新购物车中的该商品项 - } else { // 如果购物车中没有该商品 - items.put(goodsId, orderItem); // 将新的购物项添加到购物车 - } - } - - /** - * 从购物车中删除指定商品。 - * 根据商品的 ID 删除对应的购物项。 - * - * @param goodsId 商品的 ID - */ - public void delGoods(String goodsId) { - items.remove(goodsId); // 从购物车中删除指定商品 - } - - /** - * 更新购物车中某个商品的数量。 - * - * @param goodsId 商品的 ID - * @param quantity 新的商品数量 - */ - public void updateCart(String goodsId, int quantity) { - // 获取购物车中的购物项,并更新数量 - TorderItem orderItem = items.get(goodsId); - orderItem.setGoods_quantity(quantity); // 更新数量 - items.put(goodsId, orderItem); // 更新购物车中的该商品项 - } - - /** - * 获取购物车中所有商品的总价。 - * 遍历购物车中的所有商品,根据每个商品的特价和数量计算总价。 - * - * @return 购物车中所有商品的总价 - */ - public int getTotalPrice() { - int totalPrice = 0; // 初始化总价为 0 - // 遍历购物车中的所有商品 - for (Iterator it = items.values().iterator(); it.hasNext();) { - TorderItem orderItem = (TorderItem) it.next(); // 获取当前购物项 - Tgoods goods = orderItem.getGoods(); // 获取商品信息 - int quantity = orderItem.getGoods_quantity(); // 获取商品数量 - totalPrice += goods.getTejia() * quantity; // 计算该商品的总价并累加到总价 - } - return totalPrice; // 返回购物车中商品的总价 - } - - /** - * 获取购物车中的所有商品。 - * 返回一个 Map,其中 key 是商品 ID,value 是购物项。 - * - * @return 购物车中的所有商品 - */ - public Map getItems() { - return items; // 返回购物车中的所有商品 - } -} diff --git a/EncodingFilter.java b/EncodingFilter.java deleted file mode 100644 index cdaf09e..0000000 --- a/EncodingFilter.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.itbaizhan.util; - -import java.io.IOException; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; - -public class EncodingFilter implements Filter { - - // 用于存储编码格式 - protected String encoding = null; - - // 用于存储 Filter 的配置信息 - protected FilterConfig filterConfig = null; - - /** - * 销毁方法。过滤器销毁时调用。清理资源。 - */ - public void destroy() { - this.encoding = null; // 清空编码设置 - this.filterConfig = null; // 清空过滤器配置 - } - - /** - * 过滤请求和响应。 - * 在这个方法中,进行请求和响应的编码设置。 - * - * @param request 请求对象,允许访问客户端请求的内容。 - * @param response 响应对象,允许设置响应的内容。 - * @param chain FilterChain 对象,允许将请求和响应传递到下一个过滤器或目标资源(例如 Servlet)。 - * @throws IOException IO 异常 - * @throws ServletException Servlet 异常 - */ - public void doFilter(ServletRequest request, ServletResponse response, - FilterChain chain) throws IOException, ServletException { - - // 获取请求的编码格式 - String encoding = selectEncoding(request); - - // 如果编码格式不为空,则设置请求和响应的编码格式 - if (encoding != null) { - request.setCharacterEncoding(encoding); // 设置请求的编码 - response.setCharacterEncoding(encoding); // 设置响应的编码 - } - - // 将请求和响应传递给下一个过滤器或目标资源 - chain.doFilter(request, response); - } - - /** - * 初始化方法。用于初始化过滤器配置。 - * 在过滤器启动时调用,通常用于读取 web.xml 中的配置参数。 - * - * @param filterConfig 过滤器的配置信息对象 - * @throws ServletException 初始化时发生异常 - */ - public void init(FilterConfig filterConfig) throws ServletException { - this.filterConfig = filterConfig; - - // 获取 web.xml 中配置的编码格式参数 - this.encoding = filterConfig.getInitParameter("encoding"); - } - - /** - * 根据请求选择字符编码。 - * 该方法可以进行扩展,以支持不同的编码选择机制。 - * - * @param request 请求对象 - * @return 选择的字符编码 - */ - protected String selectEncoding(ServletRequest request) { - // 返回初始化时配置的编码格式 - return (this.encoding); - } -} diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..254272e --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/buy_servlet.java b/buy_servlet.java deleted file mode 100644 index 3e2def7..0000000 --- a/buy_servlet.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.itbaizhan.action; - -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Iterator; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import com.itbaizhan.orm.Tgoods; -import com.itbaizhan.orm.Torder; -import com.itbaizhan.orm.TorderItem; -import com.itbaizhan.orm.Tuser; -import com.itbaizhan.service.liuService; -import com.itbaizhan.util.Cart; - -// 继承自HttpServlet类,这是一个典型的Servlet类,用于处理客户端请求 -public class buy_servlet extends HttpServlet { - - // service方法处理所有客户端请求 - // req: HttpServletRequest请求对象,res: HttpServletResponse响应对象 - public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String type = req.getParameter("type"); // 获取URL传来的type参数,决定执行的操作 - - // 判断type的值,调用不同的操作方法 - if (type.endsWith("addToCart")) { - addToCart(req, res); // 如果操作是添加到购物车 - } - if (type.endsWith("orderSubmit")) { - orderSubmit(req, res); // 如果操作是提交订单 - } - if (type.endsWith("myorder")) { - myorder(req, res); // 如果操作是查看我的订单 - } - if (type.endsWith("orderDetail")) { - orderDetail(req, res); // 如果操作是查看订单明细 - } - } - - // 添加商品到购物车 - public void addToCart(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String goods_id = req.getParameter("goods_id"); // 获取商品ID - int quantity = Integer.parseInt(req.getParameter("quantity")); // 获取商品数量 - - // 根据商品ID获取商品详情 - Tgoods goods = liuService.getGoods(goods_id); - - // 创建订单项对象,设置商品和商品数量 - TorderItem orderItem = new TorderItem(); - orderItem.setGoods(goods); - orderItem.setGoods_quantity(quantity); - - // 获取session中的购物车对象 - HttpSession session = req.getSession(); - Cart cart = (Cart) session.getAttribute("cart"); - - // 将商品添加到购物车 - cart.addGoods(goods_id, orderItem); - - // 更新session中的购物车 - session.setAttribute("cart", cart); - - // 设置成功信息和跳转路径 - req.setAttribute("message", "操作成功"); - req.setAttribute("path", "site/cart/mycart.jsp"); // 跳转到购物车页面 - - // 跳转到成功页面 - String targetURL = "/common/success.jsp"; - dispatch(targetURL, req, res); // 跳转到目标页面 - } - - // 提交订单 - public void orderSubmit(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String songhuodizhi = req.getParameter("songhuodizhi"); // 获取送货地址 - String fukuanfangshi = req.getParameter("fukuanfangshi"); // 获取付款方式 - - // 从session中获取购物车对象和当前用户信息 - HttpSession session = req.getSession(); - Cart cart = (Cart) session.getAttribute("cart"); - Tuser user = (Tuser) session.getAttribute("user"); - - // 创建订单对象并设置相关属性 - Torder order = new Torder(); - order.setId(String.valueOf(new Date().getTime())); // 设置订单ID(使用当前时间戳) - order.setBianhao(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date())); // 设置订单编号 - order.setShijian(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date())); // 设置下单时间 - order.setZhuangtai("no"); // 订单状态,默认是“未支付” - order.setHuifu(""); // 订单回复信息 - order.setSonghuodizhi(songhuodizhi); // 送货地址 - order.setFukuanfangshi(fukuanfangshi); // 付款方式 - order.setJine(cart.getTotalPrice()); // 总金额 - order.setUser_id(user.getId()); // 用户ID - - // 保存订单到数据库 - liuService.saveOrder(order); - - // 遍历购物车中的商品项,保存订单项信息 - for (Iterator it = cart.getItems().values().iterator(); it.hasNext();) { - TorderItem orderItem = (TorderItem) it.next(); // 获取购物车中的每一项商品 - String id = String.valueOf(new Date().getTime()); // 创建一个新的订单项ID - String order_id = order.getId(); // 获取订单ID - String goods_id = orderItem.getGoods().getId(); // 获取商品ID - int goods_quantity = orderItem.getGoods_quantity(); // 获取商品数量 - - // 保存订单项信息 - liuService.saveOrderItem(id, order_id, goods_id, goods_quantity); - } - - // 清空购物车 - cart.getItems().clear(); - session.setAttribute("cart", cart); - - // 将订单信息传递到页面 - req.setAttribute("order", order); - req.getRequestDispatcher("site/order/orderSubmit.jsp").forward(req, res); // 跳转到订单提交页面 - } - - // 查看我的订单 - public void myorder(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - HttpSession session = req.getSession(); - Tuser user = (Tuser) session.getAttribute("user"); - - // 从数据库获取当前用户的所有订单 - req.setAttribute("orderList", liuService.orderList(user.getId())); - req.getRequestDispatcher("site/order/myorder.jsp").forward(req, res); // 跳转到我的订单页面 - } - - // 查看订单明细 - public void orderDetail(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String order_id = req.getParameter("order_id"); // 获取订单ID - - // 打印订单ID,调试用 - System.out.println(order_id + "DD"); - - // 从数据库获取订单项信息 - req.setAttribute("orderItemList", liuService.orderItemList(order_id)); - req.getRequestDispatcher("site/order/orderDetail.jsp").forward(req, res); // 跳转到订单明细页面 - } - - // 跳转到目标页面 - public void dispatch(String targetURI, HttpServletRequest request, HttpServletResponse response) { - RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI); - try { - dispatch.forward(request, response); // 转发请求到目标页面 - } catch (ServletException | IOException e) { - e.printStackTrace(); // 异常处理 - } - } - - // 初始化Servlet配置 - public void init(ServletConfig config) throws ServletException { - super.init(config); - } - - // 销毁Servlet,通常用来释放资源 - public void destroy() { - } -} diff --git a/cartService.java b/cartService.java deleted file mode 100644 index 3c1d666..0000000 --- a/cartService.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.itbaizhan.service; - -import javax.servlet.http.HttpSession; -import org.directwebremoting.WebContext; -import org.directwebremoting.WebContextFactory; -import com.itbaizhan.util.Cart; - -/** - * 购物车服务类 (cartService) - * - * 该类提供了对购物车的操作方法,包括修改商品数量、删除购物车中的商品以及清空购物车等功能。 - * 它通过使用 session 来保存和管理用户的购物车信息。 - */ -public class cartService { - - /** - * 修改购物车中商品的数量 - * - * @param goodsId 商品ID - * @param quantity 新的商品数量 - * @return 操作结果的字符串 ("yes" 表示成功) - */ - public String modiNum(String goodsId, int quantity) { - String result = ""; // 初始化操作结果为空 - - // 获取 WebContext 上下文 - WebContext ctx = WebContextFactory.get(); // 通过 DWR (Direct Web Remoting) 获取 WebContext - HttpSession session = ctx.getSession(); // 获取当前会话对象 - - // 获取购物车对象 - Cart cart = (Cart) session.getAttribute("cart"); - - // 更新购物车中的商品数量 - cart.updateCart(goodsId, quantity); - - // 更新 session 中的购物车对象 - session.setAttribute("cart", cart); - - // 设置操作结果为 "yes" 表示成功 - result = "yes"; - return result; - } - - /** - * 从购物车中删除指定商品 - * - * @param goodsId 商品ID - * @return 操作结果的字符串 ("yes" 表示成功) - */ - public String delGoodsFromCart(String goodsId) { - // 获取 WebContext 上下文 - WebContext ctx = WebContextFactory.get(); // 通过 DWR 获取 WebContext - HttpSession session = ctx.getSession(); // 获取当前会话对象 - - // 获取购物车对象 - Cart cart = (Cart) session.getAttribute("cart"); - - // 从购物车中删除指定商品 - cart.delGoods(goodsId); - - // 更新 session 中的购物车对象 - session.setAttribute("cart", cart); - - return "yes"; // 返回成功标志 - } - - /** - * 清空购物车中的所有商品 - * - * @return 操作结果的字符串 ("yes" 表示成功) - */ - public String clearCart() { - // 获取 WebContext 上下文 - WebContext ctx = WebContextFactory.get(); // 通过 DWR 获取 WebContext - HttpSession session = ctx.getSession(); // 获取当前会话对象 - - // 获取购物车对象 - Cart cart = (Cart) session.getAttribute("cart"); - - // 清空购物车中的所有商品 - cart.getItems().clear(); - - // 更新 session 中的购物车对象 - session.setAttribute("cart", cart); - - return "yes"; // 返回成功标志 - } -} diff --git a/catelogAdd.jsp b/catelogAdd.jsp deleted file mode 100644 index 70dc4d2..0000000 --- a/catelogAdd.jsp +++ /dev/null @@ -1,61 +0,0 @@ - <%@ page language="java" pageEncoding="UTF-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> -<%@ page isELIgnored="false" %> - -<% -String path = request.getContextPath(); -%> - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -
  
- 绫诲埆鍚嶇О锛 - - -
-   - -   -   -
-
- - diff --git a/catelogMana.jsp b/catelogMana.jsp deleted file mode 100644 index ff2528b..0000000 --- a/catelogMana.jsp +++ /dev/null @@ -1,70 +0,0 @@ -<%@ page language="java" pageEncoding="UTF-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> -<%@ page isELIgnored="false" %> -<% -String path = request.getContextPath(); -%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  
搴忓彿绫诲埆鍚嶇О鎿嶄綔
- ${sta.index+1} - - ${catelog.name} - - -
- - - - - -
- -
- - diff --git a/catelog_servlet.java b/catelog_servlet.java deleted file mode 100644 index 7d85fe0..0000000 --- a/catelog_servlet.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.itbaizhan.action; - -import java.io.IOException; -import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.itbaizhan.dao.DB; -import com.itbaizhan.orm.Tcatelog; - -// 继承HttpServlet类,处理关于菜品类别的增删改查操作 -public class catelog_servlet extends HttpServlet { - - // service方法是Servlet的核心方法,接收请求并分发到不同的功能方法 - public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String type = req.getParameter("type"); // 获取请求的type参数,判断要执行的操作类型 - - // 根据type值决定执行相应的功能 - if (type.endsWith("catelogAdd")) { - catelogAdd(req, res); // 添加菜品类别 - } - if (type.endsWith("catelogMana")) { - catelogMana(req, res); // 菜品类别管理 - } - if (type.endsWith("catelogDel")) { - catelogDel(req, res); // 删除菜品类别 - } - } - - // 添加菜品类别 - public void catelogAdd(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - // 获取请求参数,并设置类别的ID(使用当前时间戳) - String id = String.valueOf(new Date().getTime()); - String name = req.getParameter("name").trim(); // 获取类别名称并去除空格 - String del = "no"; // 设置删除标记,默认为“no”表示未删除 - - // 编写SQL插入语句,将菜品类别信息插入到数据库中 - String sql = "insert into t_catelog(id,name,del) values(?,?,?)"; - Object[] params = { id, name, del }; // 参数化SQL查询,防止SQL注入 - - // 创建DB对象并执行SQL语句 - DB mydb = new DB(); - mydb.doPstm(sql, params); // 执行SQL语句 - mydb.closed(); // 关闭数据库连接 - - // 设置操作成功消息 - req.setAttribute("msg", "操作成功"); - String targetURL = "/common/msg.jsp"; // 跳转页面路径 - dispatch(targetURL, req, res); // 跳转到成功提示页面 - } - - // 菜品类别管理,展示所有未删除的类别 - public void catelogMana(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - List catelogList = new ArrayList(); // 存储所有菜品类别的列表 - - // 查询所有未删除的菜品类别 - String sql = "select * from t_catelog where del='no'"; - Object[] params = {}; // 查询没有参数 - DB mydb = new DB(); // 创建DB对象用于执行查询操作 - - try { - mydb.doPstm(sql, params); // 执行SQL查询 - ResultSet rs = mydb.getRs(); // 获取查询结果集 - - // 循环处理查询结果 - while (rs.next()) { // 如果有更多数据,继续处理 - Tcatelog catelog = new Tcatelog(); // 创建Tcatelog对象,用于存储每个类别的信息 - catelog.setId(rs.getString("id")); // 设置类别ID - catelog.setName(rs.getString("name")); // 设置类别名称 - catelogList.add(catelog); // 将类别对象添加到列表中 - } - rs.close(); // 关闭结果集 - } catch (Exception e) { - e.printStackTrace(); // 处理异常 - } - mydb.closed(); // 关闭数据库连接 - - // 将类别列表传递到前端页面 - req.setAttribute("catelogList", catelogList); - req.getRequestDispatcher("admin/catelog/catelogMana.jsp").forward(req, res); // 跳转到类别管理页面 - } - - // 删除菜品类别(将del字段设置为“yes”表示删除) - public void catelogDel(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - // 获取请求中传递的类别ID,并执行SQL更新语句 - String sql = "update t_catelog set del='yes' where id=" + req.getParameter("id"); - Object[] params = {}; // 删除操作没有额外的参数 - DB mydb = new DB(); // 创建DB对象 - - mydb.doPstm(sql, params); // 执行更新操作 - mydb.closed(); // 关闭数据库连接 - - // 设置操作成功消息 - req.setAttribute("msg", "操作成功"); - String targetURL = "/common/msg.jsp"; // 跳转页面路径 - dispatch(targetURL, req, res); // 跳转到成功提示页面 - } - - // 跳转到指定页面 - public void dispatch(String targetURI, HttpServletRequest request, HttpServletResponse response) { - RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI); // 获取RequestDispatcher对象 - try { - dispatch.forward(request, response); // 将请求转发到目标页面 - } catch (ServletException | IOException e) { - e.printStackTrace(); // 处理异常 - } - } - - // 初始化Servlet配置 - public void init(ServletConfig config) throws ServletException { - super.init(config); // 调用父类的初始化方法 - } - - // 销毁Servlet,通常用来释放资源 - public void destroy() { - // 可以进行资源释放的操作(此处为空) - } -} diff --git a/goodsAdd.jsp b/goodsAdd.jsp deleted file mode 100644 index 041d55c..0000000 --- a/goodsAdd.jsp +++ /dev/null @@ -1,157 +0,0 @@ -<%@ page language="java" pageEncoding="UTF-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> -<%@ page isELIgnored="false" %> -<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%> - -<% -String path = request.getContextPath(); -%> - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  
- 绫诲埆锛 - - - - - - -
- - - - -
-
- 缂栧彿锛 - - -
- 鍚嶇О锛 - - -
- 浠嬬粛锛 - - - -
- 鍥剧墖锛 - - - - -
- 浠锋牸锛 - - - -
-   - -   -   -
-
- - diff --git a/goodsDetailHou.jsp b/goodsDetailHou.jsp deleted file mode 100644 index f405c49..0000000 --- a/goodsDetailHou.jsp +++ /dev/null @@ -1,24 +0,0 @@ -<%@ page language="java" pageEncoding="UTF-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> - - - - - - - - - - - - - - - - -
- -
- - diff --git a/goodsMana.jsp b/goodsMana.jsp deleted file mode 100644 index 90dd123..0000000 --- a/goodsMana.jsp +++ /dev/null @@ -1,118 +0,0 @@ -<%@ page language="java" pageEncoding="UTF-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> -<%@ page isELIgnored="false" %> -<% -String path = request.getContextPath(); -%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  
搴忓彿缂栧彿鍚嶇О浠嬬粛鍥剧墖浠锋牸鎿嶄綔
${sta.index+1}${goods.bianhao}${goods.mingcheng}鍟嗗搧鎻忚堪
鍥剧墖
${goods.shichangjia} - - -
- - - - - - -
- -
- - - - diff --git a/goodsPre.jsp b/goodsPre.jsp deleted file mode 100644 index 986c10a..0000000 --- a/goodsPre.jsp +++ /dev/null @@ -1,159 +0,0 @@ -<%@ page language="java" pageEncoding="UTF-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> -<%@ page isELIgnored="false" %> -<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%> - -<% -String path = request.getContextPath(); -%> - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  
- 绫诲埆锛 - - - - - - -
- - - -
-
- 缂栧彿锛 - - -
- 鍚嶇О锛 - - -
- 浠嬬粛锛 - - - -
- 鍥剧墖锛 - - - - -
- 浠锋牸锛 - - - -
-   - - -   -   -
-
- - diff --git a/goods_servlet.java b/goods_servlet.java deleted file mode 100644 index d5f165b..0000000 --- a/goods_servlet.java +++ /dev/null @@ -1,312 +0,0 @@ -package com.itbaizhan.action; - -import java.io.IOException; -import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.itbaizhan.dao.DB; -import com.itbaizhan.orm.Tgoods; -import com.itbaizhan.service.liuService; - -public class goods_servlet extends HttpServlet { - // 处理所有的请求,根据type来区分不同的操作 - public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String type = req.getParameter("type"); - - // 判断type并调用相应的方法进行处理 - if (type.endsWith("goodsAdd")) { - goodsAdd(req, res); // 添加商品 - } - if (type.endsWith("goodsMana")) { - goodsMana(req, res); // 商品管理 - } - if (type.endsWith("goodsDel")) { - goodsDel(req, res); // 删除商品 - } - if (type.endsWith("goodsDetailHou")) { - goodsDetailHou(req, res); // 后台查看商品详细信息 - } - if (type.endsWith("goodsPre")) { - goodsPre(req, res); // 商品信息添加前的准备工作 - } - if (type.endsWith("goodsEdit")) { - goodsEdit(req, res); // 编辑商品信息 - } - if (type.endsWith("goodsNew")) { - goodsNew(req, res); // 获取最新商品 - } - if (type.endsWith("goodsByCatelog")) { - goodsByCatelog(req, res); // 按商品类别查看商品 - } - if (type.endsWith("goodsDetailQian")) { - goodsDetailQian(req, res); // 前台查看商品详细信息 - } - if (type.endsWith("goodsRes")) { - goodsRes(req, res); // 根据商品名称搜索商品 - } - } - - // 添加商品 - public void goodsAdd(HttpServletRequest req, HttpServletResponse res) { - String id = String.valueOf(new Date().getTime()); // 使用当前时间戳作为商品 ID - String catelog_id = req.getParameter("catelog_id"); - String bianhao = req.getParameter("bianhao"); - String mingcheng = req.getParameter("mingcheng"); - String jieshao = req.getParameter("jieshao"); - String fujian = req.getParameter("fujian"); - int shichangjia = Integer.parseInt(req.getParameter("shichangjia")); - int tejia = Integer.parseInt(req.getParameter("shichangjia")); // 可能是设置的特价,暂时设置为与市场价一样 - - String del = "no"; // 标记商品未删除 - - // SQL语句插入商品数据 - String sql = "insert into t_goods(id, catelog_id, bianhao, mingcheng, jieshao, fujian, shichangjia, tejia, del) values(?,?,?,?,?,?,?,?,?)"; - Object[] params = {id, catelog_id, bianhao, mingcheng, jieshao, fujian, shichangjia, tejia, del}; - - // 使用数据库操作类执行插入操作 - DB mydb = new DB(); - mydb.doPstm(sql, params); // 执行SQL插入 - mydb.closed(); // 关闭数据库连接 - - // 返回操作成功信息并跳转至指定页面 - req.setAttribute("msg", "操作成功"); - String targetURL = "/common/msg.jsp"; - dispatch(targetURL, req, res); // 转发到操作成功页面 - } - - // 商品管理,查看所有商品 - public void goodsMana(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - List goodsList = new ArrayList(); - String sql = "select * from t_goods where del='no'"; // 查询所有未删除的商品 - Object[] params = {}; - - DB mydb = new DB(); - try { - mydb.doPstm(sql, params); // 执行查询操作 - ResultSet rs = mydb.getRs(); - while (rs.next()) { - Tgoods goods = new Tgoods(); // 创建Tgoods对象并填充数据 - goods.setId(rs.getString("id")); - goods.setCatelog_id(rs.getString("catelog_id")); - goods.setBianhao(rs.getString("bianhao")); - goods.setMingcheng(rs.getString("mingcheng")); - goods.setJieshao(rs.getString("jieshao")); - goods.setFujian(rs.getString("fujian")); - goods.setShichangjia(rs.getInt("shichangjia")); - goods.setTejia(rs.getInt("tejia")); - goods.setDel(rs.getString("del")); - goodsList.add(goods); // 将商品添加到列表中 - } - rs.close(); - } catch (Exception e) { - e.printStackTrace(); - } - mydb.closed(); // 关闭数据库连接 - - // 将商品列表传递到前端页面 - req.setAttribute("goodsList", goodsList); - req.getRequestDispatcher("admin/goods/goodsMana.jsp").forward(req, res); - } - - // 删除商品 - public void goodsDel(HttpServletRequest req, HttpServletResponse res) { - String id = req.getParameter("id"); - String sql = "update t_goods set del='yes' where id=" + id; // 更新商品的del字段为'yes'表示删除 - Object[] params = {}; - - DB mydb = new DB(); - mydb.doPstm(sql, params); // 执行删除操作 - mydb.closed(); - - req.setAttribute("msg", "操作成功"); - String targetURL = "/common/msg.jsp"; - dispatch(targetURL, req, res); // 转发到操作成功页面 - } - - // 后台查看商品详细信息 - public void goodsDetailHou(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String id = req.getParameter("id"); - - req.setAttribute("goods", liuService.getGoods(id)); // 从服务层获取商品详细信息 - req.getRequestDispatcher("admin/goods/goodsDetailHou.jsp").forward(req, res); - } - - // 商品信息添加前的准备工作 - public void goodsPre(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - Tgoods goods = new Tgoods(); - String sql = "select * from t_goods where id=?"; - Object[] params = {req.getParameter("id")}; - - DB mydb = new DB(); - try { - mydb.doPstm(sql, params); // 执行查询操作 - ResultSet rs = mydb.getRs(); - while (rs.next()) { - goods.setId(rs.getString("id")); - goods.setCatelog_id(rs.getString("catelog_id")); - goods.setBianhao(rs.getString("bianhao")); - goods.setMingcheng(rs.getString("mingcheng")); - goods.setJieshao(rs.getString("jieshao")); - goods.setFujian(rs.getString("fujian")); - goods.setShichangjia(rs.getInt("shichangjia")); - goods.setTejia(rs.getInt("tejia")); - goods.setDel(rs.getString("del")); - } - rs.close(); - } catch (Exception e) { - e.printStackTrace(); - } - mydb.closed(); - - req.setAttribute("goods", goods); // 将商品信息传递到前端页面 - req.getRequestDispatcher("admin/goods/goodsPre.jsp").forward(req, res); - } - - // 编辑商品信息 - public void goodsEdit(HttpServletRequest req, HttpServletResponse res) { - String id = req.getParameter("id"); - String catelog_id = req.getParameter("catelog_id"); - String bianhao = req.getParameter("bianhao"); - String mingcheng = req.getParameter("mingcheng"); - String jieshao = req.getParameter("jieshao"); - String fujian = req.getParameter("fujian"); - int shichangjia = Integer.parseInt(req.getParameter("shichangjia")); - int tejia = Integer.parseInt(req.getParameter("shichangjia")); - - // 更新商品信息 - String sql = "update t_goods set catelog_id=?, bianhao=?, mingcheng=?, jieshao=?, fujian=?, shichangjia=?, tejia=? where id=?"; - Object[] params = {catelog_id, bianhao, mingcheng, jieshao, fujian, shichangjia, tejia, id}; - - DB mydb = new DB(); - mydb.doPstm(sql, params); // 执行更新操作 - mydb.closed(); - - req.setAttribute("msg", "操作成功"); - String targetURL = "/common/msg.jsp"; - dispatch(targetURL, req, res); // 转发到操作成功页面 - } - - // 获取最新商品 - public void goodsNew(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - List goodsList = new ArrayList(); - String sql = "select * from t_goods where del='no' order by id desc"; // 按商品ID降序排列,查询所有未删除的商品 - Object[] params = {}; - - DB mydb = new DB(); - try { - mydb.doPstm(sql, params); // 执行查询操作 - ResultSet rs = mydb.getRs(); - while (rs.next()) { - Tgoods goods = new Tgoods(); // 创建Tgoods对象并填充数据 - goods.setId(rs.getString("id")); - goods.setCatelog_id(rs.getString("catelog_id")); - goods.setBianhao(rs.getString("bianhao")); - goods.setMingcheng(rs.getString("mingcheng")); - goods.setJieshao(rs.getString("jieshao")); - goods.setFujian(rs.getString("fujian")); - goods.setShichangjia(rs.getInt("shichangjia")); - goods.setTejia(rs.getInt("tejia")); - goods.setDel(rs.getString("del")); - goodsList.add(goods); // 将商品添加到列表中 - } - rs.close(); - } catch (Exception e) { - e.printStackTrace(); - } - mydb.closed(); // 关闭数据库连接 - - // 限制最新商品显示数量最多为4个 - if (goodsList.size() > 4) { - goodsList = goodsList.subList(0, 4); // 截取前4个商品 - } - - // 将商品列表传递到前端页面 - req.setAttribute("goodsList", goodsList); - req.getRequestDispatcher("site/goods/goodsNew.jsp").forward(req, res); // 转发到前端页面显示最新商品 - } - - // 根据商品类别查看商品 - public void goodsByCatelog(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String catelog_id = req.getParameter("catelog_id"); - - // 从服务层获取指定类别的商品列表 - req.setAttribute("goodsList", liuService.goodsByCatelog(catelog_id)); - req.getRequestDispatcher("site/goods/goodsByCatelog.jsp").forward(req, res); // 转发到前端页面显示商品类别 - } - - // 前台查看商品详细信息 - public void goodsDetailQian(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String id = req.getParameter("id"); - - // 从服务层获取商品的详细信息 - req.setAttribute("goods", liuService.getGoods(id)); - req.getRequestDispatcher("site/goods/goodsDetailQian.jsp").forward(req, res); // 转发到前端页面显示商品详细信息 - } - - // 根据商品名称搜索商品 - public void goodsRes(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String mingcheng = req.getParameter("mingcheng"); - - List goodsList = new ArrayList(); - String sql = "select * from t_goods where del='no' and mingcheng like '%" + mingcheng.trim() + "%'"; // 根据商品名称进行模糊查询 - Object[] params = {}; - - DB mydb = new DB(); - try { - mydb.doPstm(sql, params); // 执行查询操作 - ResultSet rs = mydb.getRs(); - while (rs.next()) { - Tgoods goods = new Tgoods(); // 创建Tgoods对象并填充数据 - goods.setId(rs.getString("id")); - goods.setCatelog_id(rs.getString("catelog_id")); - goods.setBianhao(rs.getString("bianhao")); - goods.setMingcheng(rs.getString("mingcheng")); - goods.setJieshao(rs.getString("jieshao")); - goods.setFujian(rs.getString("fujian")); - goods.setShichangjia(rs.getInt("shichangjia")); - goods.setTejia(rs.getInt("tejia")); - goods.setDel(rs.getString("del")); - goodsList.add(goods); // 将商品添加到列表中 - } - rs.close(); - } catch (Exception e) { - e.printStackTrace(); - } - mydb.closed(); // 关闭数据库连接 - - // 将商品列表传递到前端页面 - req.setAttribute("goodsList", goodsList); - req.getRequestDispatcher("site/goods/goodsRes.jsp").forward(req, res); // 转发到前端页面显示搜索结果 - } - - // 转发请求到指定页面 - public void dispatch(String targetURI, HttpServletRequest request, HttpServletResponse response) { - RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI); - try { - dispatch.forward(request, response); // 转发请求到目标页面 - } catch (ServletException e) { - e.printStackTrace(); // 捕获并打印异常 - } catch (IOException e) { - e.printStackTrace(); // 捕获并打印异常 - } - } - - // 初始化方法,初始化Servlet时调用 - public void init(ServletConfig config) throws ServletException { - super.init(config); // 调用父类的init()方法进行初始化 - } - - // 销毁方法,在Servlet销毁时调用 - public void destroy() { - // 在Servlet销毁时执行清理工作,如果有的话 - } -} diff --git a/index_servlet.java b/index_servlet.java deleted file mode 100644 index 1daeb81..0000000 --- a/index_servlet.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.itbaizhan.action; - -import java.io.IOException; -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.itbaizhan.service.liuService; - -public class index_servlet extends HttpServlet -// 导航页面服务端小程序 -{ - /** - * service方法是处理请求的核心方法 - * 这个方法会接收客户端的请求,并做出响应。 - * 1. 从服务层获取商品分类数据 - * 2. 将数据保存到session中,以便前端页面使用 - * 3. 转发请求到首页(index.jsp) - */ - public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException - { - // 从liuService类中获取商品分类数据,并将其保存到session中 - req.getSession().setAttribute("catelogList", liuService.catelogList()); - - // 转发请求到首页index.jsp页面,这个页面会使用“catelogList”来展示商品分类 - req.getRequestDispatcher("site/index.jsp").forward(req, res); - } - - /** - * dispatch方法用于请求的转发 - * 用于将请求转发到指定的目标URI。 - * 这里传入的目标URI通常是JSP页面,用于显示数据。 - */ - public void dispatch(String targetURI, HttpServletRequest request, HttpServletResponse response) - { - RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI); // 获取请求转发器 - - try - { - // 转发请求到目标页面 - dispatch.forward(request, response); - return; - } - catch (ServletException e) - { - e.printStackTrace(); // 捕获并打印ServletException - } - catch (IOException e) - { - e.printStackTrace(); // 捕获并打印IOException - } - } - - /** - * init方法用于Servlet初始化时的设置 - * 在Servlet创建时调用,用于做一些必要的初始化工作。 - * 这里调用了父类的init()方法,但没有额外的初始化逻辑。 - */ - public void init(ServletConfig config) throws ServletException - { - super.init(config); // 调用父类的init()方法进行初始化 - } - - /** - * destroy方法在Servlet销毁时调用 - * 可以用来释放资源,如关闭数据库连接、清理内存等。 - * 这里没有特别的销毁逻辑,留作将来扩展使用。 - */ - public void destroy() - { - // 销毁时执行清理工作,如果需要 - } -} diff --git a/js/popup.js b/js/popup.js new file mode 100644 index 0000000..908b32f --- /dev/null +++ b/js/popup.js @@ -0,0 +1,188 @@ +锘縱ar tcolor={ + cColor:"#EEEEEE", //钂欑毊棰滆壊 + bColor:"#FFFFFF", //鑳屾櫙棰滆壊 + tColor:"#9C9E9C", //鏍囬鑳屾櫙棰滆壊锛岃竟妗嗛鑹 + wColor:"#FFFFFF" //鏍囬鏂囧瓧棰滆壊 + }; + +function popclose() +{ +var a = parent.document.getElementById("dialogBoxClose"); +a.click(); +} + +if(!Array.prototype.push){ +Array.prototype.push=function(){ + var startLength=this.length; + for(var i=0;i'; + var close=''; + var cB='filter: alpha(opacity='+this.info.coverOpacity+');opacity:'+this.info.coverOpacity/100+';'; + var cover=''; + var mainBox=''+''; + if(!this.config.isBackgroundCanClick){G('dialogCase').innerHTML=cover+mainBox;G('dialogBoxBG').style.height=document.body.scrollHeight} + else G('dialogCase').innerHTML=mainBox;Event.observe(G('dialogBoxClose'),"click",this.reset.bindAsEventListener(this),false); + if(this.config.isSupportDraging){dropClass=new Dragdrop(this.config.width,this.config.height,this.info.shadowWidth,this.config.isSupportDraging,this.config.contentType);G("dialogBoxTitle").style.cursor="move"};this.lastBuild()},lastBuild:function(){var confirm='
'+this.info.confirmCon+'
 
'; + var alert='
'+this.info.alertCon+'
'; + var baseZIndex=10001+this.info.overlay*10;var coverIfZIndex=baseZIndex+4; + if(this.config.contentType==1){var openIframe=""; + var coverIframe="
";G("dialogBody").innerHTML=openIframe+coverIframe} + else if(this.config.contentType==2){G("dialogBody").innerHTML=this.info.contentHtml}else if(this.config.contentType==3){G("dialogBody").innerHTML=confirm;Event.observe(G('dialogOk'),"click",this.forCallback.bindAsEventListener(this),false); + Event.observe(G('dialogCancel'),"click",this.close.bindAsEventListener(this),false)}else if(this.config.contentType==4){G("dialogBody").innerHTML=alert;Event.observe(G('dialogYES'),"click",this.close.bindAsEventListener(this),false)}},reBuild:function(){G('dialogBody').height=G('dialogBody').clientHeight;this.lastBuild()},show:function(){this.hiddenSome();this.middle();if(this.config.isShowShadow)this.shadow()},forCallback:function(){return this.info.callBack(this.info.parameter)},shadow:function(){var oShadow=G('dialogBoxShadow');var oDialog=G('dialogBox');oShadow['style']['position']="absolute";oShadow['style']['background']="#000";oShadow['style']['display']="";oShadow['style']['opacity']="0.2";oShadow['style']['filter']="alpha(opacity=20)";oShadow['style']['top']=oDialog.offsetTop+this.info.shadowWidth;oShadow['style']['left']=oDialog.offsetLeft+this.info.shadowWidth;oShadow['style']['width']=oDialog.offsetWidth;oShadow['style']['height']=oDialog.offsetHeight},middle:function(){if(!this.config.isBackgroundCanClick)G('dialogBoxBG').style.display=''; + var oDialog=G('dialogBox'); + oDialog['style']['position']="absolute"; + oDialog['style']['display']=''; + //鍙栧緱椤甸潰鐨勫搴﹀拰楂樺害 + var sClientWidth=document.body.clientWidth; + var sClientHeight=document.body.clientHeight; + var sScrollTop=document.body.scrollTop; + // + var sleft=(sClientWidth/2)-(oDialog.offsetWidth/2); + var iTop=-80+(sClientHeight/2+sScrollTop)-(oDialog.offsetHeight/2); + var sTop=iTop>0?iTop:(sClientHeight/2+sScrollTop)-(oDialog.offsetHeight/2); + if(sTop<1)sTop="20";if(sleft<1)sleft="20"; + oDialog['style']['left']=sleft+"px"; //宸︿晶浣嶇疆 + oDialog['style']['top']=220+"px" //椤堕儴浣嶇疆 + }, + reset:function(){if(this.config.isReloadOnClose){top.location.reload()};this.close()},close:function(){G('dialogBox').style.display='none'; + if(!this.config.isBackgroundCanClick)G('dialogBoxBG').style.display='none'; + if(this.config.isShowShadow)G('dialogBoxShadow').style.display='none';G('dialogBody').innerHTML=''; + this.showSome()},hiddenSome:function(){var tag=this.info.someHiddenTag.split(","); + if(tag.length==1&&tag[0]=="")tag.length=0; + for(var i=0;iparseInt(this.oObj.style.top)+25)iTop=iTop+12;this.oObj.style.left=iLeft;this.oObj.style.top=iTop;if(this.showShadow){G('dialogBoxShadow').style.left=iLeft+this.shadowWidth;G('dialogBoxShadow').style.top=iTop+this.shadowWidth};this.dragData={x:Event.pointerX(event),y:Event.pointerY(event)};document.body.style.cursor="move"},mouseup:function(event){if(!this.IsDraging)return;if(this.contentType==1)G("iframeBG").style.display="none";document.onmousemove=null;document.onmouseup=null;var mousX=Event.pointerX(event)-(document.documentElement.scrollLeft||document.body.scrollLeft);var mousY=Event.pointerY(event)-(document.documentElement.scrollTop||document.body.scrollTop);if(mousX<1||mousY<1||mousX>document.body.clientWidth||mousY>document.body.clientHeight){this.oObj.style.left=this.backData["x"];this.oObj.style.top=this.backData["y"];if(this.showShadow){G('dialogBoxShadow').style.left=this.backData.x+this.shadowWidth;G('dialogBoxShadow').style.top=this.backData.y+this.shadowWidth}};this.IsDraging=false;document.body.style.cursor="";Event.stopObserving(document,"selectstart",this.returnFalse,false)},returnFalse:function(){return false}}; + + + diff --git a/js/popup_shuaxin.js b/js/popup_shuaxin.js new file mode 100644 index 0000000..c298f21 --- /dev/null +++ b/js/popup_shuaxin.js @@ -0,0 +1,188 @@ +锘縱ar tcolor={ + cColor:"#EEEEEE", //钂欑毊棰滆壊 + bColor:"#FFFFFF", //鑳屾櫙棰滆壊 + tColor:"#9C9E9C", //鏍囬鑳屾櫙棰滆壊锛岃竟妗嗛鑹 + wColor:"#FFFFFF" //鏍囬鏂囧瓧棰滆壊 + }; + +function popclose() +{ +var a = parent.document.getElementById("dialogBoxClose"); +a.click(); +} + +if(!Array.prototype.push){ +Array.prototype.push=function(){ + var startLength=this.length; + for(var i=0;i'; + var close=''; + var cB='filter: alpha(opacity='+this.info.coverOpacity+');opacity:'+this.info.coverOpacity/100+';'; + var cover=''; + var mainBox=''+''; + if(!this.config.isBackgroundCanClick){G('dialogCase').innerHTML=cover+mainBox;G('dialogBoxBG').style.height=document.body.scrollHeight} + else G('dialogCase').innerHTML=mainBox;Event.observe(G('dialogBoxClose'),"click",this.reset.bindAsEventListener(this),false); + if(this.config.isSupportDraging){dropClass=new Dragdrop(this.config.width,this.config.height,this.info.shadowWidth,this.config.isSupportDraging,this.config.contentType);G("dialogBoxTitle").style.cursor="move"};this.lastBuild()},lastBuild:function(){var confirm='
'+this.info.confirmCon+'
 
'; + var alert='
'+this.info.alertCon+'
'; + var baseZIndex=10001+this.info.overlay*10;var coverIfZIndex=baseZIndex+4; + if(this.config.contentType==1){var openIframe=""; + var coverIframe="
";G("dialogBody").innerHTML=openIframe+coverIframe} + else if(this.config.contentType==2){G("dialogBody").innerHTML=this.info.contentHtml}else if(this.config.contentType==3){G("dialogBody").innerHTML=confirm;Event.observe(G('dialogOk'),"click",this.forCallback.bindAsEventListener(this),false); + Event.observe(G('dialogCancel'),"click",this.close.bindAsEventListener(this),false)}else if(this.config.contentType==4){G("dialogBody").innerHTML=alert;Event.observe(G('dialogYES'),"click",this.close.bindAsEventListener(this),false)}},reBuild:function(){G('dialogBody').height=G('dialogBody').clientHeight;this.lastBuild()},show:function(){this.hiddenSome();this.middle();if(this.config.isShowShadow)this.shadow()},forCallback:function(){return this.info.callBack(this.info.parameter)},shadow:function(){var oShadow=G('dialogBoxShadow');var oDialog=G('dialogBox');oShadow['style']['position']="absolute";oShadow['style']['background']="#000";oShadow['style']['display']="";oShadow['style']['opacity']="0.2";oShadow['style']['filter']="alpha(opacity=20)";oShadow['style']['top']=oDialog.offsetTop+this.info.shadowWidth;oShadow['style']['left']=oDialog.offsetLeft+this.info.shadowWidth;oShadow['style']['width']=oDialog.offsetWidth;oShadow['style']['height']=oDialog.offsetHeight},middle:function(){if(!this.config.isBackgroundCanClick)G('dialogBoxBG').style.display=''; + var oDialog=G('dialogBox'); + oDialog['style']['position']="absolute"; + oDialog['style']['display']=''; + //鍙栧緱椤甸潰鐨勫搴﹀拰楂樺害 + var sClientWidth=document.body.clientWidth; + var sClientHeight=document.body.clientHeight; + var sScrollTop=document.body.scrollTop; + // + var sleft=(sClientWidth/2)-(oDialog.offsetWidth/2); + var iTop=-80+(sClientHeight/2+sScrollTop)-(oDialog.offsetHeight/2); + var sTop=iTop>0?iTop:(sClientHeight/2+sScrollTop)-(oDialog.offsetHeight/2); + if(sTop<1)sTop="20";if(sleft<1)sleft="20"; + oDialog['style']['left']=sleft+"px"; //宸︿晶浣嶇疆 + oDialog['style']['top']=220+"px" //椤堕儴浣嶇疆 + }, + reset:function(){if(this.config.isReloadOnClose){top.location.reload()};this.close()},close:function(){G('dialogBox').style.display='none';window.location.reload(); + if(!this.config.isBackgroundCanClick)G('dialogBoxBG').style.display='none'; + if(this.config.isShowShadow)G('dialogBoxShadow').style.display='none';G('dialogBody').innerHTML=''; + this.showSome()},hiddenSome:function(){var tag=this.info.someHiddenTag.split(","); + if(tag.length==1&&tag[0]=="")tag.length=0; + for(var i=0;iparseInt(this.oObj.style.top)+25)iTop=iTop+12;this.oObj.style.left=iLeft;this.oObj.style.top=iTop;if(this.showShadow){G('dialogBoxShadow').style.left=iLeft+this.shadowWidth;G('dialogBoxShadow').style.top=iTop+this.shadowWidth};this.dragData={x:Event.pointerX(event),y:Event.pointerY(event)};document.body.style.cursor="move"},mouseup:function(event){if(!this.IsDraging)return;if(this.contentType==1)G("iframeBG").style.display="none";document.onmousemove=null;document.onmouseup=null;var mousX=Event.pointerX(event)-(document.documentElement.scrollLeft||document.body.scrollLeft);var mousY=Event.pointerY(event)-(document.documentElement.scrollTop||document.body.scrollTop);if(mousX<1||mousY<1||mousX>document.body.clientWidth||mousY>document.body.clientHeight){this.oObj.style.left=this.backData["x"];this.oObj.style.top=this.backData["y"];if(this.showShadow){G('dialogBoxShadow').style.left=this.backData.x+this.shadowWidth;G('dialogBoxShadow').style.top=this.backData.y+this.shadowWidth}};this.IsDraging=false;document.body.style.cursor="";Event.stopObserving(document,"selectstart",this.returnFalse,false)},returnFalse:function(){return false}}; + + + diff --git a/js/popup_shuaxin_no.js b/js/popup_shuaxin_no.js new file mode 100644 index 0000000..908b32f --- /dev/null +++ b/js/popup_shuaxin_no.js @@ -0,0 +1,188 @@ +锘縱ar tcolor={ + cColor:"#EEEEEE", //钂欑毊棰滆壊 + bColor:"#FFFFFF", //鑳屾櫙棰滆壊 + tColor:"#9C9E9C", //鏍囬鑳屾櫙棰滆壊锛岃竟妗嗛鑹 + wColor:"#FFFFFF" //鏍囬鏂囧瓧棰滆壊 + }; + +function popclose() +{ +var a = parent.document.getElementById("dialogBoxClose"); +a.click(); +} + +if(!Array.prototype.push){ +Array.prototype.push=function(){ + var startLength=this.length; + for(var i=0;i'; + var close=''; + var cB='filter: alpha(opacity='+this.info.coverOpacity+');opacity:'+this.info.coverOpacity/100+';'; + var cover=''; + var mainBox=''+''; + if(!this.config.isBackgroundCanClick){G('dialogCase').innerHTML=cover+mainBox;G('dialogBoxBG').style.height=document.body.scrollHeight} + else G('dialogCase').innerHTML=mainBox;Event.observe(G('dialogBoxClose'),"click",this.reset.bindAsEventListener(this),false); + if(this.config.isSupportDraging){dropClass=new Dragdrop(this.config.width,this.config.height,this.info.shadowWidth,this.config.isSupportDraging,this.config.contentType);G("dialogBoxTitle").style.cursor="move"};this.lastBuild()},lastBuild:function(){var confirm='
'+this.info.confirmCon+'
 
'; + var alert='
'+this.info.alertCon+'
'; + var baseZIndex=10001+this.info.overlay*10;var coverIfZIndex=baseZIndex+4; + if(this.config.contentType==1){var openIframe=""; + var coverIframe="
";G("dialogBody").innerHTML=openIframe+coverIframe} + else if(this.config.contentType==2){G("dialogBody").innerHTML=this.info.contentHtml}else if(this.config.contentType==3){G("dialogBody").innerHTML=confirm;Event.observe(G('dialogOk'),"click",this.forCallback.bindAsEventListener(this),false); + Event.observe(G('dialogCancel'),"click",this.close.bindAsEventListener(this),false)}else if(this.config.contentType==4){G("dialogBody").innerHTML=alert;Event.observe(G('dialogYES'),"click",this.close.bindAsEventListener(this),false)}},reBuild:function(){G('dialogBody').height=G('dialogBody').clientHeight;this.lastBuild()},show:function(){this.hiddenSome();this.middle();if(this.config.isShowShadow)this.shadow()},forCallback:function(){return this.info.callBack(this.info.parameter)},shadow:function(){var oShadow=G('dialogBoxShadow');var oDialog=G('dialogBox');oShadow['style']['position']="absolute";oShadow['style']['background']="#000";oShadow['style']['display']="";oShadow['style']['opacity']="0.2";oShadow['style']['filter']="alpha(opacity=20)";oShadow['style']['top']=oDialog.offsetTop+this.info.shadowWidth;oShadow['style']['left']=oDialog.offsetLeft+this.info.shadowWidth;oShadow['style']['width']=oDialog.offsetWidth;oShadow['style']['height']=oDialog.offsetHeight},middle:function(){if(!this.config.isBackgroundCanClick)G('dialogBoxBG').style.display=''; + var oDialog=G('dialogBox'); + oDialog['style']['position']="absolute"; + oDialog['style']['display']=''; + //鍙栧緱椤甸潰鐨勫搴﹀拰楂樺害 + var sClientWidth=document.body.clientWidth; + var sClientHeight=document.body.clientHeight; + var sScrollTop=document.body.scrollTop; + // + var sleft=(sClientWidth/2)-(oDialog.offsetWidth/2); + var iTop=-80+(sClientHeight/2+sScrollTop)-(oDialog.offsetHeight/2); + var sTop=iTop>0?iTop:(sClientHeight/2+sScrollTop)-(oDialog.offsetHeight/2); + if(sTop<1)sTop="20";if(sleft<1)sleft="20"; + oDialog['style']['left']=sleft+"px"; //宸︿晶浣嶇疆 + oDialog['style']['top']=220+"px" //椤堕儴浣嶇疆 + }, + reset:function(){if(this.config.isReloadOnClose){top.location.reload()};this.close()},close:function(){G('dialogBox').style.display='none'; + if(!this.config.isBackgroundCanClick)G('dialogBoxBG').style.display='none'; + if(this.config.isShowShadow)G('dialogBoxShadow').style.display='none';G('dialogBody').innerHTML=''; + this.showSome()},hiddenSome:function(){var tag=this.info.someHiddenTag.split(","); + if(tag.length==1&&tag[0]=="")tag.length=0; + for(var i=0;iparseInt(this.oObj.style.top)+25)iTop=iTop+12;this.oObj.style.left=iLeft;this.oObj.style.top=iTop;if(this.showShadow){G('dialogBoxShadow').style.left=iLeft+this.shadowWidth;G('dialogBoxShadow').style.top=iTop+this.shadowWidth};this.dragData={x:Event.pointerX(event),y:Event.pointerY(event)};document.body.style.cursor="move"},mouseup:function(event){if(!this.IsDraging)return;if(this.contentType==1)G("iframeBG").style.display="none";document.onmousemove=null;document.onmouseup=null;var mousX=Event.pointerX(event)-(document.documentElement.scrollLeft||document.body.scrollLeft);var mousY=Event.pointerY(event)-(document.documentElement.scrollTop||document.body.scrollTop);if(mousX<1||mousY<1||mousX>document.body.clientWidth||mousY>document.body.clientHeight){this.oObj.style.left=this.backData["x"];this.oObj.style.top=this.backData["y"];if(this.showShadow){G('dialogBoxShadow').style.left=this.backData.x+this.shadowWidth;G('dialogBoxShadow').style.top=this.backData.y+this.shadowWidth}};this.IsDraging=false;document.body.style.cursor="";Event.stopObserving(document,"selectstart",this.returnFalse,false)},returnFalse:function(){return false}}; + + + diff --git a/js/public.js b/js/public.js new file mode 100644 index 0000000..e738129 --- /dev/null +++ b/js/public.js @@ -0,0 +1,474 @@ +锘/* + * 鎵撳紑鏂扮獥鍙 f:閾炬帴鍦板潃 n:绐楀彛鐨勫悕绉 w:绐楀彛鐨勫搴 h:绐楀彛鐨勯珮搴 s:绐楀彛鏄惁鏈夋粴鍔ㄦ潯锛1锛氭湁婊氬姩鏉★紱0锛氭病鏈夋粴鍔ㄦ潯 + */ + + + +function openWin(f, n, w, h, s) +{ + var result=window.open(f,n,"dialogHeight:"+h+";dialogWidth:"+w+";"+s); + if(result==true) + { + window.location.reload(true); + } + else + { + //window.location.reload(true); + } + +} + + + + + +/* + * 鍒犻櫎璁板綍 + */ +function del(url, info) +{ + //if (openDeleteDialog(url, info)) + //{ + //window.location.reload(true); + //} + if (confirm(info)) + { + var result=window.open(url,"window123","dialogHeight:234px;dialogWidth:271px;resizable:no;help:no;status:no;scroll:no"); + if(result==true) + { + window.location.reload(true); + } + else + { + + } + } + else + { + + } +} + + + +/* + * 鏍¢獙checkbox + */ +function checkAll(chkName, checkboxName, pageSize) { + var src = event.srcElement; + var chkN = eval("document.all." + chkName); + + if (src.checked) { + chkN[0].checked = true; + chkN[1].checked = true; + for (var i = 0; i < pageSize; i++) { + var chk = eval("document.all." + checkboxName + i); + if (chk) { + chk.checked = true; + } + } + } else { + chkN[0].checked = false; + chkN[1].checked = false; + for (var i = 0; i < pageSize; i++) { + var chk = eval("document.all." + checkboxName + i); + if (chk) { + chk.checked = false; + } + } + } +} + +/* + * + */ +function makePages(maxPage, selectedPage, selectName) { + var sel = eval("document.all." + selectName); + sel.length = 0; + for (var i = 1; i <= maxPage; i++) { + sel.options[i] = new Option(i, i); + if (sel.options[i] == selectedPage) { + sel.options[i].selected = true; + } + } +} + + + +/* + * 鏇挎崲瀛楃涓 + */ +function replaceStr(str) { + var re = "/( )/gi"; + str = str.replace(re, ""); + re = "/\= 0 && whitespace.indexOf(s.charAt(i)) != -1) { + i--; + } + s = s.substring(0, i + 1); + } + return s; +} + +/* + * 鍘绘帀涓よ竟绌烘牸 + */ +function Trim(str) { + return RTrim(LTrim(str)); +} + + + + +/* + * + */ +function exeOperation(exePath) { + var obj = new ActiveXObject("Microsoft.XMLHTTP"); + obj.open("post", exePath, false); + obj.send(); + var res = obj.responseText; + var rs = Trim(res); + if (rs.indexOf('true', 0) != -1) { + return true; + } else { + return false; + } +} + +/* + * + */ +function exeValidate(exePath) { + var obj = new ActiveXObject("Microsoft.XMLHTTP"); + obj.open("post", exePath, false); + obj.send(); + var res = obj.responseText; + var rs = Trim(res); + if (rs.indexOf('validate_login_user', 0) != -1) { + return true; + } else { + return false; + } +} + + + +/* + * 鏄剧ず + */ +function validate_date(exePath) { + var obj = new ActiveXObject("Microsoft.XMLHTTP"); + obj.open("post", exePath, false); + obj.send(); + var res = obj.responseText; + var rs = Trim(res); + var begin_str = ""; + var beginIndex = rs.indexOf(begin_str) + begin_str.length; + var endIndex = rs.indexOf(""); + rs = ((beginIndex >= 0) && (endIndex >= 0)) ? rs.substring(beginIndex, + endIndex) : ""; + return Trim(rs); +} + +/* + * 鏍¢獙鏄惁鏁板瓧 + */ +function checkNumber(name, TempS) { + for (Count = 0; Count < TempS.length; Count++) { + TempChar = TempS.substring(Count, Count + 1); + RefString = "0123456789"; + if (RefString.indexOf(TempChar, 0) == -1) { + alert("璇疯緭鍏ユ暟瀛"); + eval("document.all." + name).focus(); + return false; + } + } +} + + + +/* + * 鏄惁鏈夐潪娉曞瓧绗 + */ +function chksafe(a) { + fibdn = new Array("'", "\\"); + i = fibdn.length; + j = a.length; + for (ii = 0; ii < i; ii++) { + for (jj = 0; jj < j; jj++) { + temp1 = a.charAt(jj); + temp2 = fibdn[ii]; + if (temp1 == temp2) { + return false; + } + } + } + return true; +} + +/* + * + */ +function fucCheckNUM(NUM) { + var i, j, strTemp; + strTemp = "0123456789"; + if (NUM.length == 0) + return false; + for (i = 0; i < NUM.length; i++) { + j = strTemp.indexOf(NUM.charAt(i)); + if (j == -1) { + return false; + } + } + return true; +} + + + +/* + * + */ +function fucCheckLength(strTemp) { + var i, sum; + sum = 0; + for (i = 0; i < strTemp.length; i++) { + if ((strTemp.charCodeAt(i) >= 0) && (strTemp.charCodeAt(i) <= 255)) { + sum = sum + 1; + } else { + sum = sum + 2; + } + } + return sum; +} + +/* + * + */ +function chkElements(name, errMsg, max_length, lengthMsg) { + var el_name = eval("document.all." + name); + var v = el_name.value; + if (!chksafe(v)) { + el_name.focus(); + alert(errMsg); + return false; + } else if (fucCheckLength(v) > max_length) { + el_name.focus(); + alert(lengthMsg); + return false; + } + return true; +} + + + +/* + * 鏍¢獙绌哄瓧绗︿覆 + */ +function checkNullStr(name, msg) { + var el_name = eval("document.all." + name); + if (Trim(el_name.value).length == 0) { + alert(msg); + el_name.focus(); + return false; + } + return true; +} + + + + +/* + * 鏄剧ず鏃ユ湡鎺ian + */ +function GetDate(nText, para) { + var v_url = para == "1" ? "./common/data.html" : "../../common/data.html"; + var reVal = window + .open( + v_url, + 'data', + "status:no;center:yes;scroll:no;resizable:no;dialogWidth:255px;dialogHeight:260px"); + if (reVal != null) { + var n = eval("document.all." + nText); + n.value = reVal; + } +} + + + +/* + * 鎸夋瘮渚嬬缉灏忓浘鐗 + */ +function DrawImage(ImgD, iwidth, iheight) { + var flag = false; + var image = new Image(); + image.src = ImgD.src; + if (image.width > 0 && image.height > 0) { + flag = true; + if (image.width / image.height >= iwidth / iheight) { + if (image.width > iwidth) { + ImgD.width = iwidth; + ImgD.height = (image.height * iwidth) / image.width; + } else { + ImgD.width = image.width; + ImgD.height = image.height; + } + // ImgD.alt=image.width+"脳"+image.height; + } else { + if (image.height > iheight) { + ImgD.height = iheight; + ImgD.width = (image.width * iheight) / image.height; + } else { + ImgD.width = image.width; + ImgD.height = image.height; + } + // ImgD.alt=image.width+"脳"+image.height; + } + } + ImgD.style.visibility = "visible"; +} + + + +/* + * 鍥炶溅閿浆涓篢ab閿 + */ +function enterTab() { + if (event.keyCode == 13) { + oElement = document.activeElement; + if (oElement.tagName != "TEXTAREA" && oElement.type != "button") + event.keyCode = 9; + return; + } +} + +/* + * + */ +function objectEval(text) { + text = text.replace(/\n/g, " "); + text = text.replace(/\r/g, " "); + if (text.match(/^\s*\{.*\}\s*$/)) { + text = "[" + text + "]"; + } + return eval(text)[0]; +} + + + +/* + * 鎵撳紑棰嗗鏌ヨ椤甸潰 action - 鏌ヨ鐨凙ction method - 璋冪敤鐨勬柟娉 title - 鏍囬message name - + * 鍛樺伐閫夋嫨鍩熺殑name + */ +function openLeaderQuery(action, method, title, name) { + openWin("../../common/selectStaff.jsp?action=" + action + "&method=" + + method + "&title=" + title + "&name=" + name, + "public_leader_find_page", "400", "150"); +} + +/* + * 绗竴琛屽彉鑹 + */ +function chgColor() { + var v_table = document.all["PowerTable"]; + var v_row = v_table.rows[1]; + var len = v_row.cells.length; + for (var i = 0; i < len; i++) { + var v_cell = v_row.cells[i]; + v_cell.style.backgroundColor = "yellow"; + } +} + +/* + * 绗竴琛屽彉鑹 + */ +function chgColor2() { + var v_table = document.all["PowerTable"]; + var rows_count = v_table.rows.length; + var v_row, v_cell, temp_len, len; + var rowspan = 0; + + // get rowspan + if (v_table.rows.length > 1) { + len = v_table.rows[1].cells.length; + for (var r = 2; r < rows_count; r++) { + v_row = v_table.rows[r]; + temp_len = v_row.cells.length; + if (temp_len == len) { + rowspan = r - 1; + break; + } + } + + rowspan = (rowspan > 0) ? (rowspan + 1) : rows_count; + for (var r = 1; r < rowspan; r++) { + v_row = v_table.rows[r]; + for (var t = 0; t < v_row.cells.length; t++) { + v_cell = v_row.cells[t]; + v_cell.style.backgroundColor = "yellow"; + } + } + } +} + + + +/* + * 娣诲姞椤甸潰杞藉叆鍚庤Е鍙戠殑shijian + */ +function addLoadEvent(func) { + var oldonload = window.onload; + if (typeof(window.onload) != "function") { + window.onload = func; + } else { + window.onload = function() { + oldonload(); + func(); + } + } +} + + + +// adsName:鍚嶇О,adsUrl:鍦板潃,sTime:鏃堕棿(灏忔椂) add by wujie 2005.12.12 +function PopAds(adsName, adsUrl, sTime, number, w, h, s) { + if (document.cookie.indexOf(adsName) == -1) { + window.open(adsUrl, adsName); + self.focus(); + var expireDate = new Date(); + var lefttime = 1000 * (3600 * sTime); + expireDate.setTime(expireDate.getTime() + lefttime); + document.cookie = adsName + "=yes" + "; expires=" + + expireDate.toGMTString() + ";"; + } + openWin(adsUrl, number, w, h, s); +} diff --git a/liuService.java b/liuService.java deleted file mode 100644 index fbe817a..0000000 --- a/liuService.java +++ /dev/null @@ -1,344 +0,0 @@ -package com.itbaizhan.service; - -import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; - -import com.itbaizhan.dao.DB; -import com.itbaizhan.orm.Tcatelog; -import com.itbaizhan.orm.Tgoods; -import com.itbaizhan.orm.Torder; -import com.itbaizhan.orm.TorderItem; -import com.itbaizhan.orm.Txinyong; - -/** - * 服务类:liuService - * - * 该类提供了多个与商品、订单、用户等相关的业务逻辑功能。它包含了查询商品、保存订单、更新库存、处理用户登录等功能。 - */ -public class liuService { - - /** - * 获取菜品种类的列表,返回菜品类别的 ID 和名称 - * - * @return 返回菜品种类的 List,包含每个菜品的 ID 和名称 - */ - public static List catelogList() { - List catelogList = new ArrayList(); // 初始化菜品种类列表 - String sql = "select * from t_catelog where del='no'"; // 查询未被删除的菜品种类 - Object[] params = {}; // 设置查询参数为空 - DB mydb = new DB(); - - try { - mydb.doPstm(sql, params); // 执行 SQL 查询 - ResultSet rs = mydb.getRs(); // 获取查询结果集 - while (rs.next()) { // 遍历结果集 - Tcatelog catelog = new Tcatelog(); // 创建 Tcatelog 对象 - catelog.setId(rs.getString("id")); // 设置菜品类别 ID - catelog.setName(rs.getString("name")); // 设置菜品类别名称 - catelogList.add(catelog); // 将菜品类别添加到列表 - } - rs.close(); // 关闭结果集 - } catch (Exception e) { - e.printStackTrace(); - } - mydb.closed(); // 关闭数据库连接 - return catelogList; // 返回菜品类别列表 - } - - /** - * 获取商品详细信息 - * - * @param id 商品 ID - * @return 返回商品详细信息的 Tgoods 对象 - */ - public static Tgoods getGoods(String id) { - Tgoods goods = new Tgoods(); // 初始化商品对象 - String sql = "select * from t_goods where id=?"; // 查询指定商品的 SQL 语句 - Object[] params = { id }; // 设置查询参数为商品 ID - DB mydb = new DB(); - - try { - mydb.doPstm(sql, params); // 执行查询 - ResultSet rs = mydb.getRs(); // 获取查询结果集 - rs.next(); // 移动到第一行(只查询一条记录) - - // 设置商品属性 - goods.setId(rs.getString("id")); - goods.setCatelog_id(rs.getString("catelog_id")); - goods.setBianhao(rs.getString("bianhao")); - goods.setMingcheng(rs.getString("mingcheng")); - goods.setJieshao(rs.getString("jieshao")); - goods.setFujian(rs.getString("fujian")); - goods.setShichangjia(rs.getInt("shichangjia")); - goods.setTejia(rs.getInt("tejia")); - goods.setDel(rs.getString("del")); - - rs.close(); // 关闭结果集 - } catch (Exception e) { - e.printStackTrace(); - } - mydb.closed(); // 关闭数据库连接 - return goods; // 返回商品对象 - } - - /** - * 获取最新商品的信息(按商品 ID 排序,最多返回前 8 个商品) - * - * @return 返回最新商品列表 - */ - public static List goodsNew() { - List goodsList = new ArrayList(); // 初始化商品列表 - String sql = "select * from t_goods where del='no' order by id desc"; // 查询未删除的商品,按 ID 降序排列 - Object[] params = {}; // 设置查询参数为空 - DB mydb = new DB(); - - try { - mydb.doPstm(sql, params); // 执行查询 - ResultSet rs = mydb.getRs(); // 获取查询结果集 - while (rs.next()) { // 遍历结果集 - Tgoods goods = new Tgoods(); // 创建 Tgoods 对象 - - // 设置商品属性 - goods.setId(rs.getString("id")); - goods.setCatelog_id(rs.getString("catelog_id")); - goods.setBianhao(rs.getString("bianhao")); - goods.setMingcheng(rs.getString("mingcheng")); - goods.setJieshao(rs.getString("jieshao")); - goods.setFujian(rs.getString("fujian")); - goods.setShichangjia(rs.getInt("shichangjia")); - goods.setTejia(rs.getInt("tejia")); - goods.setDel(rs.getString("del")); - - goodsList.add(goods); // 将商品添加到列表 - } - rs.close(); // 关闭结果集 - } catch (Exception e) { - e.printStackTrace(); - } - mydb.closed(); // 关闭数据库连接 - - // 限制返回最多 8 个商品 - if (goodsList.size() > 8) { - goodsList = goodsList.subList(0, 8); - } - return goodsList; // 返回最新商品列表 - } - - /** - * 根据菜品类别 ID 获取该类别下的商品列表 - * - * @param catelog_id 菜品类别 ID - * @return 返回该类别下的商品列表 - */ - public static List goodsByCatelog(String catelog_id) { - List goodsList = new ArrayList(); // 初始化商品列表 - String sql = "select * from t_goods where del='no' and catelog_id=? order by id desc"; // 根据类别 ID 查询商品 - Object[] params = { catelog_id }; // 设置查询参数为菜品类别 ID - DB mydb = new DB(); - - try { - mydb.doPstm(sql, params); // 执行查询 - ResultSet rs = mydb.getRs(); // 获取查询结果集 - while (rs.next()) { // 遍历结果集 - Tgoods goods = new Tgoods(); // 创建 Tgoods 对象 - - // 设置商品属性 - goods.setId(rs.getString("id")); - goods.setCatelog_id(rs.getString("catelog_id")); - goods.setBianhao(rs.getString("bianhao")); - goods.setMingcheng(rs.getString("mingcheng")); - goods.setJieshao(rs.getString("jieshao")); - goods.setFujian(rs.getString("fujian")); - goods.setShichangjia(rs.getInt("shichangjia")); - goods.setTejia(rs.getInt("tejia")); - goods.setDel(rs.getString("del")); - - goodsList.add(goods); // 将商品添加到列表 - } - rs.close(); // 关闭结果集 - } catch (Exception e) { - e.printStackTrace(); - } - mydb.closed(); // 关闭数据库连接 - return goodsList; // 返回商品列表 - } - - /** - * 保存订单信息 - * - * @param order 订单对象,包含订单的各项信息 - */ - public static void saveOrder(Torder order) { - String sql = "insert into t_order(id,bianhao,shijian,zhuangtai,huifu,songhuodizhi,fukuanfangshi,jine,user_id) values(?,?,?,?,?,?,?,?,?)"; - Object[] params = { order.getId(), order.getBianhao(), order.getShijian(), order.getZhuangtai(), - order.getHuifu(), order.getSonghuodizhi(), order.getFukuanfangshi(), order.getJine(), order.getUser_id() }; - DB mydb = new DB(); - mydb.doPstm(sql, params); // 执行插入操作 - mydb.closed(); // 关闭数据库连接 - } - - /** - * 保存订单商品明细 - * - * @param id 订单明细 ID - * @param order_id 订单 ID - * @param goods_id 商品 ID - * @param goods_quantity 商品数量 - */ - public static void saveOrderItem(String id, String order_id, String goods_id, int goods_quantity) { - String sql = "insert into t_orderitem(id,order_id,goods_id,goods_quantity) values(?,?,?,?)"; - Object[] params = { id, order_id, goods_id, goods_quantity }; - DB mydb = new DB(); - mydb.doPstm(sql, params); // 执行插入操作 - mydb.closed(); // 关闭数据库连接 - } - - /** - * 更新商品库存 - * - * @param goods_id 商品 ID - * @param goods_quantity 商品数量 - */ - public static void updateGoodsKucun(String goods_id, int goods_quantity) { - String sql = "update t_goods set kucun=kucun-? where id=?"; - Object[] params = { goods_quantity, goods_id }; - DB mydb = new DB(); - mydb.doPstm(sql, params); // 执行更新操作 - mydb.closed(); // 关闭数据库连接 - } - - /** - * 获取用户的订单列表 - * - * @param user_id 用户 ID - * @return 返回该用户的订单列表 - */ - public static List orderList(String user_id) { - List orderList = new ArrayList(); // 初始化订单列表 - String sql = "select * from t_order where user_id=?"; // 查询该用户的所有订单 - Object[] params = { user_id }; // 设置查询参数为用户 ID - DB mydb = new DB(); - - try { - mydb.doPstm(sql, params); // 执行查询 - ResultSet rs = mydb.getRs(); // 获取查询结果集 - while (rs.next()) { // 遍历结果集 - Torder order = new Torder(); // 创建 Torder 对象 - - // 设置订单属性 - order.setId(rs.getString("id")); - order.setBianhao(rs.getString("bianhao")); - order.setShijian(rs.getString("shijian")); - order.setZhuangtai(rs.getString("zhuangtai")); - order.setHuifu(rs.getString("huifu")); - order.setSonghuodizhi(rs.getString("songhuodizhi")); - order.setFukuanfangshi(rs.getString("fukuanfangshi")); - order.setJine(rs.getInt("jine")); - order.setUser_id(rs.getString("user_id")); - - orderList.add(order); // 将订单添加到列表 - } - rs.close(); // 关闭结果集 - } catch (Exception e) { - e.printStackTrace(); - } - mydb.closed(); // 关闭数据库连接 - return orderList; // 返回订单列表 - } - - /** - * 获取订单商品的详细信息列表 - * - * @param order_id 订单 ID - * @return 返回订单商品的列表,包含商品信息和数量 - */ - public static List orderItemList(String order_id) { - List orderitemList = new ArrayList(); // 初始化订单商品列表 - String sql = "select * from t_orderitem where order_id=?"; // 查询订单中包含的商品 - Object[] params = { order_id }; // 设置查询参数为订单 ID - DB mydb = new DB(); - - try { - mydb.doPstm(sql, params); // 执行查询 - ResultSet rs = mydb.getRs(); // 获取查询结果集 - while (rs.next()) { // 遍历结果集 - TorderItem orderItem = new TorderItem(); // 创建 TorderItem 对象 - - // 设置订单商品属性 - orderItem.setId(rs.getString("id")); - orderItem.setGoods(getGoods(rs.getString("goods_id"))); // 获取商品信息 - orderItem.setGoods_quantity(rs.getInt("goods_quantity")); // 设置商品数量 - - orderitemList.add(orderItem); // 将订单商品添加到列表 - } - rs.close(); // 关闭结果集 - } catch (Exception e) { - e.printStackTrace(); - } - mydb.closed(); // 关闭数据库连接 - return orderitemList; // 返回订单商品列表 - } - - /** - * 判断用户的账号是否存在 - * - * @param loginname 用户登录账号 - * @return 如果账号存在,返回 "yizhan",否则返回 "meizhan" - */ - public static String panduan_zhanghao(String loginname) { - String s = "meizhan"; // 默认返回“没占用” - - String sql = "select * from t_user where del='no' and loginname=?"; // 查询账号是否存在 - Object[] params = { loginname.trim() }; // 设置查询参数为账号 - DB mydb = new DB(); - - try { - mydb.doPstm(sql, params); // 执行查询 - ResultSet rs = mydb.getRs(); // 获取查询结果集 - while (rs.next()) { // 如果查询到结果,表示账号已存在 - s = "yizhan"; // 账号已占用 - } - rs.close(); // 关闭结果集 - } catch (Exception e) { - e.printStackTrace(); - } - mydb.closed(); // 关闭数据库连接 - return s; // 返回账号是否已占用 - } - - /** - * 获取用户的信用信息列表 - * - * @param user_id 用户 ID - * @return 返回该用户的信用信息列表 - */ - public static List getxinyongList(String user_id) { - List xinyongList = new ArrayList(); // 初始化信用信息列表 - String sql = "select * from t_xinyong where user_id=?"; // 查询该用户的信用信息 - Object[] params = { user_id }; // 设置查询参数为用户 ID - DB mydb = new DB(); - - try { - mydb.doPstm(sql, params); // 执行查询 - ResultSet rs = mydb.getRs(); // 获取查询结果集 - while (rs.next()) { // 遍历结果集 - Txinyong xinyong = new Txinyong(); // 创建 Txinyong 对象 - - // 设置信用信息属性 - xinyong.setId(rs.getString("id")); - xinyong.setShuxing(rs.getString("shuxing")); - xinyong.setNeirong(rs.getString("neirong")); - xinyong.setShijian(rs.getString("shijian")); - xinyong.setUser_id(rs.getString("user_id")); - - xinyongList.add(xinyong); // 将信用信息添加到列表 - } - rs.close(); // 关闭结果集 - } catch (Exception e) { - e.printStackTrace(); - } - mydb.closed(); // 关闭数据库连接 - return xinyongList; // 返回信用信息列表 - } -} diff --git a/liuyanMana.jsp b/liuyanMana.jsp deleted file mode 100644 index 9de707b..0000000 --- a/liuyanMana.jsp +++ /dev/null @@ -1,80 +0,0 @@ -<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> -<%@ page isELIgnored="false" %> - -<% -String path = request.getContextPath(); -%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  
搴忓彿淇℃伅鍐呭鍙戝竷鏃堕棿鍥炲淇℃伅鍥炲鏃堕棿鎿嶄綔
- ${sta.index+1 } - - ${liuyan.neirong } - - ${liuyan.liuyanshi } - - ${liuyan.huifu } - - ${liuyan.huifushi } - - - -
- - diff --git a/liuyan_servlet.java b/liuyan_servlet.java deleted file mode 100644 index a191a26..0000000 --- a/liuyan_servlet.java +++ /dev/null @@ -1,299 +0,0 @@ -package com.itbaizhan.action; - -import java.io.IOException; -import java.sql.ResultSet; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import com.itbaizhan.dao.DB; -import com.itbaizhan.orm.TLiuyan; -import com.itbaizhan.orm.Tuser; - -public class liuyan_servlet extends HttpServlet -{ - /** - * service方法用于处理客户端请求,区分不同的请求类型, - * 并调用相应的方法来处理留言的增、删、查、改操作。 - */ - public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException - { - // 获取请求的type参数来确定操作类型 - String type = req.getParameter("type"); - - // 根据请求的操作类型,调用相应的方法 - if(type.endsWith("liuyanAdd")) - { - liuyanAdd(req, res); // 留言添加 - } - if(type.endsWith("liuyanMana")) - { - liuyanMana(req, res); // 留言管理 - } - if(type.endsWith("liuyanDel")) - { - liuyanDel(req, res); // 留言删除 - } - if(type.endsWith("liuyanHuifu")) - { - liuyanHuifu(req, res); // 留言回复 - } - if(type.endsWith("liuyanAll")) - { - liuyanAll(req, res); // 获取所有留言 - } - if(type.endsWith("liuyanDetail")) - { - liuyanDetail(req, res); // 留言详细信息 - } - } - - /** - * liuyanAdd方法用于处理添加留言的操作。 - * 获取留言内容,保存到数据库,并跳转到提示页面。 - */ - public void liuyanAdd(HttpServletRequest req,HttpServletResponse res) - { - HttpSession session = req.getSession(); - Tuser user = (Tuser)session.getAttribute("user"); // 从session中获取当前登录用户 - - // 获取留言内容 - String neirong = req.getParameter("neirong"); - String liuyanshi = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()); // 当前时间 - String user_id = user.getId(); // 获取用户ID - String huifu = ""; // 默认无回复 - String huifushi = ""; // 默认无回复时间 - - // 构建SQL插入语句 - String sql = "insert into t_liuyan(neirong, liuyanshi, user_id, huifu, huifushi) values(?,?,?,?,?)"; - Object[] params = {neirong, liuyanshi, user_id, huifu, huifushi}; - - DB mydb = new DB(); // 创建DB对象 - mydb.doPstm(sql, params); // 执行SQL语句 - mydb.closed(); // 关闭数据库连接 - - req.setAttribute("msg", "留言完毕"); // 设置提示信息 - String targetURL = "/common/msg.jsp"; // 定义跳转页面 - dispatch(targetURL, req, res); // 请求转发到提示页面 - } - - /** - * liuyanMana方法用于管理留言。 - * 从数据库获取所有留言,并将其显示在管理页面。 - */ - public void liuyanMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException - { - List liuyanList = new ArrayList(); - String sql = "select * from t_liuyan order by liuyanshi"; // 获取所有留言的SQL语句 - Object[] params = {}; - DB mydb = new DB(); // 创建DB对象 - try - { - mydb.doPstm(sql, params); // 执行SQL查询 - ResultSet rs = mydb.getRs(); // 获取结果集 - while(rs.next()) // 遍历结果集 - { - TLiuyan liuyan = new TLiuyan(); // 创建留言对象 - - liuyan.setId(rs.getInt("id")); - liuyan.setNeirong(rs.getString("neirong")); - liuyan.setLiuyanshi(rs.getString("liuyanshi")); - liuyan.setUser_id(rs.getString("user_id")); - liuyan.setHuifu(rs.getString("huifu")); - liuyan.setHuifushi(rs.getString("huifushi")); - - liuyanList.add(liuyan); // 将留言添加到列表中 - } - rs.close(); // 关闭结果集 - } - catch(Exception e) - { - e.printStackTrace(); // 打印异常 - } - mydb.closed(); // 关闭数据库连接 - - req.setAttribute("liuyanList", liuyanList); // 将留言列表设置到请求属性中 - req.getRequestDispatcher("admin/liuyan/liuyanMana.jsp").forward(req, res); // 转发到留言管理页面 - } - - /** - * liuyanDel方法用于删除指定ID的留言。 - * 从数据库删除对应留言数据,并跳转到提示页面。 - */ - public void liuyanDel(HttpServletRequest req,HttpServletResponse res) - { - String sql = "delete from t_liuyan where id=" + Integer.parseInt(req.getParameter("id")); // 删除留言的SQL语句 - Object[] params = {}; - DB mydb = new DB(); // 创建DB对象 - mydb.doPstm(sql, params); // 执行删除操作 - mydb.closed(); // 关闭数据库连接 - - req.setAttribute("msg", "留言信息删除完毕"); // 设置删除成功的提示信息 - String targetURL = "/common/msg.jsp"; // 定义跳转页面 - dispatch(targetURL, req, res); // 请求转发到提示页面 - } - - /** - * liuyanHuifu方法用于回复留言。 - * 获取回复内容,并将其更新到数据库中,同时跳转到提示页面。 - */ - public void liuyanHuifu(HttpServletRequest req,HttpServletResponse res) - { - String huifu = req.getParameter("huifu"); // 获取回复内容 - String huifushi = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()); // 回复时间 - int id = Integer.parseInt(req.getParameter("id")); // 获取留言ID - - // 更新留言的回复内容和时间 - String sql = "update t_liuyan set huifu=?, huifushi=? where id=?"; - Object[] params = {huifu, huifushi, id}; - DB mydb = new DB(); // 创建DB对象 - mydb.doPstm(sql, params); // 执行更新操作 - mydb.closed(); // 关闭数据库连接 - - req.setAttribute("msg", "回复完毕"); // 设置回复成功的提示信息 - String targetURL = "/common/msg.jsp"; // 定义跳转页面 - dispatch(targetURL, req, res); // 请求转发到提示页面 - } - - /** - * liuyanAll方法用于获取所有留言。 - * 从数据库获取所有留言数据并显示在前端页面。 - */ - public void liuyanAll(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException - { - List liuyanList = new ArrayList(); - String sql = "select * from t_liuyan order by liuyanshi"; // 获取所有留言的SQL语句 - Object[] params = {}; - DB mydb = new DB(); // 创建DB对象 - try - { - mydb.doPstm(sql, params); // 执行SQL查询 - ResultSet rs = mydb.getRs(); // 获取结果集 - while(rs.next()) // 遍历结果集 - { - TLiuyan liuyan = new TLiuyan(); // 创建留言对象 - - liuyan.setId(rs.getInt("id")); - liuyan.setNeirong(rs.getString("neirong")); - liuyan.setLiuyanshi(rs.getString("liuyanshi")); - liuyan.setUser_id(rs.getString("user_id")); - liuyan.setHuifu(rs.getString("huifu")); - liuyan.setHuifushi(rs.getString("huifushi")); - - liuyanList.add(liuyan); // 将留言添加到列表中 - } - rs.close(); // 关闭结果集 - } - catch(Exception e) - { - e.printStackTrace(); // 打印异常 - } - mydb.closed(); // 关闭数据库连接 - - req.setAttribute("liuyanList", liuyanList); // 将留言列表设置到请求属性中 - req.getRequestDispatcher("site/liuyan/liuyanAll.jsp").forward(req, res); // 转发到留言展示页面 - } - - /** - * liuyanDetail方法用于查看指定ID的留言详细信息。 - * 从数据库中查询特定ID的留言,并将其显示在详细信息页面。 - */ - public void liuyanDetail(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException - { - int id = Integer.parseInt(req.getParameter("id")); // 获取留言ID - - // 获取留言的详细信息 - req.setAttribute("liuyan", get_liuyan(id)); - - // 转发到留言详细页面显示内容 - req.getRequestDispatcher("site/liuyan/liuyanDetail.jsp").forward(req, res); - } - - /** - * get_liuyan方法用于根据留言ID从数据库中查询并返回该留言对象。 - * @param id 留言ID - * @return 返回查询到的留言对象 - */ - public TLiuyan get_liuyan(int id) - { - TLiuyan liuyan = new TLiuyan(); // 创建留言对象 - - // 查询特定ID的留言数据 - String sql = "select * from t_liuyan where id=?"; - Object[] params = {id}; - DB mydb = new DB(); // 创建DB对象 - try - { - mydb.doPstm(sql, params); // 执行SQL查询 - ResultSet rs = mydb.getRs(); // 获取结果集 - while(rs.next()) // 遍历结果集 - { - liuyan.setId(rs.getInt("id")); - liuyan.setNeirong(rs.getString("neirong")); - liuyan.setLiuyanshi(rs.getString("liuyanshi")); - liuyan.setUser_id(rs.getString("user_id")); - liuyan.setHuifu(rs.getString("huifu")); - liuyan.setHuifushi(rs.getString("huifushi")); - } - rs.close(); // 关闭结果集 - } - catch(Exception e) - { - e.printStackTrace(); // 打印异常 - } - mydb.closed(); // 关闭数据库连接 - - return liuyan; // 返回留言对象 - } - - /** - * dispatch方法用于将请求转发到指定的目标页面。 - * @param targetURI 目标页面的URI - * @param request 请求对象 - * @param response 响应对象 - */ - public void dispatch(String targetURI, HttpServletRequest request, HttpServletResponse response) - { - // 获取目标URI的RequestDispatcher - RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI); - try - { - dispatch.forward(request, response); // 请求转发 - } - catch (ServletException e) - { - e.printStackTrace(); // 打印异常 - } - catch (IOException e) - { - e.printStackTrace(); // 打印异常 - } - } - - /** - * init方法用于初始化Servlet配置。 - * @param config Servlet配置对象 - */ - public void init(ServletConfig config) throws ServletException - { - super.init(config); // 调用父类的初始化方法 - } - - /** - * destroy方法用于销毁Servlet实例。 - * 在Servlet销毁时清理资源,通常不需要在此类中做额外处理。 - */ - public void destroy() - { - // 在此方法中可以释放一些资源,如数据库连接等。 - } -} diff --git a/loginService.java b/loginService.java deleted file mode 100644 index 72aeb9e..0000000 --- a/loginService.java +++ /dev/null @@ -1,166 +0,0 @@ -package com.itbaizhan.service; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.http.HttpSession; - -import org.directwebremoting.WebContext; -import org.directwebremoting.WebContextFactory; - -import com.itbaizhan.dao.DB; -import com.itbaizhan.orm.TAdmin; -import com.itbaizhan.orm.Tcatelog; -import com.itbaizhan.orm.Tuser; -import com.itbaizhan.util.Cart; - -public class loginService { - - /** - * 用户登录方法 - * 根据用户类型判断登录的身份,并验证账号密码。 - * 登录成功后,将用户信息存入 session 中。 - * - * @param userName 用户名 - * @param userPw 密码 - * @param userType 用户类型(0:管理员,1:会员,2:其他) - * @return 登录结果,"yes" 表示登录成功,"no" 表示登录失败 - */ - public String login(String userName, String userPw, int userType) { - String result = "no"; // 默认登录失败 - - if (userType == 0) { // 系统管理员登录 - String sql = "select * from t_admin where userName=? and userPw=?"; - Object[] params = { userName, userPw }; - DB mydb = new DB(); - mydb.doPstm(sql, params); - try { - ResultSet rs = mydb.getRs(); // 获取查询结果集 - boolean mark = (rs == null || !rs.next() ? false : true); // 判断查询结果是否为空 - if (!mark) { - result = "no"; // 登录失败 - } else { - result = "yes"; // 登录成功 - TAdmin admin = new TAdmin(); - admin.setUserId(rs.getInt("userId")); - admin.setUserName(rs.getString("userName")); - admin.setUserPw(rs.getString("userPw")); - - WebContext ctx = WebContextFactory.get(); // 获取 WebContext 对象 - HttpSession session = ctx.getSession(); - session.setAttribute("userType", 0); // 设置用户类型为管理员 - session.setAttribute("admin", admin); // 将管理员信息存入 session - } - rs.close(); - } catch (SQLException e) { - System.out.println("登录失败!"); - e.printStackTrace(); - } finally { - mydb.closed(); - } - } - - if (userType == 1) { // 会员登录 - String sql = "select * from t_user where loginname=? and loginpw=? and del='no'"; - Object[] params = { userName, userPw }; - DB mydb = new DB(); - try { - mydb.doPstm(sql, params); // 执行 SQL 查询 - ResultSet rs = mydb.getRs(); // 获取查询结果集 - boolean mark = (rs == null || !rs.next() ? false : true); // 判断查询结果是否为空 - if (!mark) { - result = "no"; // 登录失败 - } else { - result = "yes"; // 登录成功 - Tuser user = new Tuser(); - user.setId(rs.getString("id")); - user.setLoginname(rs.getString("loginname")); - user.setLoginpw(rs.getString("loginpw")); - user.setName(rs.getString("name")); - user.setDel(rs.getString("del")); - - WebContext ctx = WebContextFactory.get(); // 获取 WebContext 对象 - HttpSession session = ctx.getSession(); - session.setAttribute("userType", 1); // 设置用户类型为会员 - session.setAttribute("user", user); // 将用户信息存入 session - - // 创建一个空的购物车对象,存入 session - Cart cart = new Cart(); - session.setAttribute("cart", cart); - } - rs.close(); - } catch (Exception e) { - e.printStackTrace(); - } - mydb.closed(); - } - - if (userType == 2) { - // 用户类型为 2 的登录逻辑可以在这里添加(暂未实现) - } - return result; // 返回登录结果 - } - - /** - * 修改管理员密码 - * 管理员修改密码功能。 - * - * @param userPwNew 新密码 - * @return 修改结果,"yes" 表示修改成功 - */ - public String adminPwEdit(String userPwNew) { - System.out.println("DDDD"); - try { - Thread.sleep(700); // 确保线程运行顺序 - } catch (InterruptedException e) { - e.printStackTrace(); - } - - WebContext ctx = WebContextFactory.get(); // 获取 WebContext 对象 - HttpSession session = ctx.getSession(); - TAdmin admin = (TAdmin) session.getAttribute("admin"); // 获取当前登录的管理员对象 - - String sql = "update t_admin set userPw=? where userId=?"; - Object[] params = { userPwNew, admin.getUserId() }; // 设置更新的参数 - DB mydb = new DB(); - mydb.doPstm(sql, params); // 执行更新操作 - - return "yes"; // 返回修改成功的结果 - } - - /** - * 获取所有菜品类别 - * 查询所有未删除的菜品类别并返回结果。 - * - * @return 菜品类别列表 - */ - public List catelogAll() { - try { - Thread.sleep(700); // 确保线程运行顺序 - } catch (InterruptedException e) { - e.printStackTrace(); - } - - List catelogList = new ArrayList(); // 初始化菜品类别列表 - String sql = "select * from t_catelog where del='no'"; // 查询未删除的菜品类别 - Object[] params = {}; - DB mydb = new DB(); - try { - mydb.doPstm(sql, params); // 执行查询 - ResultSet rs = mydb.getRs(); // 获取查询结果集 - while (rs.next()) { // 遍历结果集 - Tcatelog catelog = new Tcatelog(); - catelog.setId(rs.getString("id")); // 设置菜品类别 ID - catelog.setName(rs.getString("name")); // 设置菜品类别名称 - catelogList.add(catelog); // 将菜品类别添加到列表 - } - rs.close(); - } catch (Exception e) { - e.printStackTrace(); - } - mydb.closed(); // 关闭数据库连接 - return catelogList; // 返回菜品类别列表 - } -} diff --git a/orderMana.jsp b/orderMana.jsp deleted file mode 100644 index 96607b1..0000000 --- a/orderMana.jsp +++ /dev/null @@ -1,121 +0,0 @@ -<%@ page language="java" pageEncoding="UTF-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> -<%@ page isELIgnored="false" %> -<% -String path = request.getContextPath(); -%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  
搴忓彿璁㈠崟缂栧彿涓嬪崟鏃堕棿鐘舵鎺掗槦璁℃椂閫佽揣鍦板潃浠樻鏂瑰紡鎬婚噾棰鏄庣粏鐢ㄦ埛淇℃伅鎿嶄綔
${ss.index+1}${order.bianhao}${order.shijian} - - 鏈彈鐞   鍙楃悊璁㈠崟 - - - 宸插彈鐞 - - - ${order.huifu} -    璁℃椂 - - ${order.songhuodizhi}${order.fukuanfangshi}${order.jine} - -
- - diff --git a/order_servlet.java b/order_servlet.java deleted file mode 100644 index 1048704..0000000 --- a/order_servlet.java +++ /dev/null @@ -1,194 +0,0 @@ -package com.itbaizhan.action; - -import java.io.IOException; -import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.itbaizhan.dao.DB; -import com.itbaizhan.orm.Torder; - -public class order_servlet extends HttpServlet { - - /** - * service方法根据请求的类型(type)来决定调用哪个处理方法。 - * @param req HttpServletRequest对象,包含请求参数和数据 - * @param res HttpServletResponse对象,用于返回响应数据 - * @throws ServletException Servlet异常 - * @throws IOException I/O异常 - */ - public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - // 获取请求的type参数来判断要执行的操作 - String type = req.getParameter("type"); - - if (type.endsWith("orderMana")) { - orderMana(req, res); // 订单管理 - } - if (type.endsWith("orderDel")) { - orderDel(req, res); // 订单删除 - } - if (type.endsWith("orderShouli")) { - orderShouli(req, res); // 受理订单 - } - - if (type.endsWith("huifuAdd")) { - huifuAdd(req, res); // 添加回复 - } - } - - /** - * orderMana方法用于查询所有订单并展示在管理页面。 - * 查询数据库中所有订单,并将其保存到request中供JSP页面显示。 - * @param req HttpServletRequest对象 - * @param res HttpServletResponse对象 - * @throws ServletException Servlet异常 - * @throws IOException I/O异常 - */ - public void orderMana(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - List orderList = new ArrayList(); // 用来保存订单列表 - String sql = "select * from t_order order by zhuangtai desc"; // 查询所有订单,按状态倒序排列 - Object[] params = {}; // SQL语句参数,当前查询没有参数 - - DB mydb = new DB(); // 创建DB对象来操作数据库 - try { - mydb.doPstm(sql, params); // 执行SQL查询 - ResultSet rs = mydb.getRs(); // 获取查询结果集 - while (rs.next()) { - Torder order = new Torder(); // 创建Torder对象来封装每一条订单数据 - - // 从结果集中提取每个字段的值,并设置到Torder对象中 - order.setId(rs.getString("id")); - order.setBianhao(rs.getString("bianhao")); - order.setShijian(rs.getString("shijian")); - order.setZhuangtai(rs.getString("zhuangtai")); - order.setHuifu(rs.getString("huifu")); - order.setSonghuodizhi(rs.getString("songhuodizhi")); - order.setFukuanfangshi(rs.getString("fukuanfangshi")); - order.setJine(rs.getInt("jine")); - order.setUser_id(rs.getString("user_id")); - - // 将订单添加到订单列表 - orderList.add(order); - } - rs.close(); // 关闭结果集 - } catch (Exception e) { - e.printStackTrace(); // 捕获异常并打印堆栈信息 - } - mydb.closed(); // 关闭数据库连接 - - // 将订单列表保存到request中,以便JSP页面进行展示 - req.setAttribute("orderList", orderList); - req.getRequestDispatcher("admin/order/orderMana.jsp").forward(req, res); // 请求转发到订单管理页面 - } - - /** - * orderDel方法用于删除指定ID的订单。 - * @param req HttpServletRequest对象 - * @param res HttpServletResponse对象 - * @throws ServletException Servlet异常 - * @throws IOException I/O异常 - */ - public void orderDel(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String id = req.getParameter("id"); // 获取要删除订单的ID - - // 编写SQL语句删除指定ID的订单 - String sql = "delete from t_order where id=?"; - Object[] params = { id }; // 设置参数为订单ID - DB mydb = new DB(); // 创建DB对象 - mydb.doPstm(sql, params); // 执行删除操作 - mydb.closed(); // 关闭数据库连接 - - // 设置删除成功的消息,并转发到消息页面显示 - req.setAttribute("msg", "信息删除完毕"); - String targetURL = "/common/msg.jsp"; - dispatch(targetURL, req, res); - } - - /** - * orderShouli方法用于受理订单,将订单状态更改为已受理。 - * @param req HttpServletRequest对象 - * @param res HttpServletResponse对象 - * @throws ServletException Servlet异常 - * @throws IOException I/O异常 - */ - public void orderShouli(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String id = req.getParameter("id"); // 获取要受理的订单ID - - // 编写SQL语句更新订单的状态为"yes"(已受理) - String sql = "update t_order set zhuangtai='yes' where id=?"; - Object[] params = { id }; // 设置参数为订单ID - DB mydb = new DB(); // 创建DB对象 - mydb.doPstm(sql, params); // 执行更新操作 - mydb.closed(); // 关闭数据库连接 - - // 设置受理成功的消息,并转发到消息页面显示 - req.setAttribute("msg", "订单受理完毕"); - String targetURL = "/common/msg.jsp"; - dispatch(targetURL, req, res); - } - - /** - * huifuAdd方法用于为订单添加回复信息。 - * @param req HttpServletRequest对象 - * @param res HttpServletResponse对象 - * @throws ServletException Servlet异常 - * @throws IOException I/O异常 - */ - public void huifuAdd(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String id = req.getParameter("id"); // 获取订单ID - String huifu = req.getParameter("huifu"); // 获取回复内容 - - // 编写SQL语句更新订单的回复内容 - String sql = "update t_order set huifu=? where id=?"; - Object[] params = { huifu, id }; // 设置参数为回复内容和订单ID - DB mydb = new DB(); // 创建DB对象 - mydb.doPstm(sql, params); // 执行更新操作 - mydb.closed(); // 关闭数据库连接 - - // 设置回复成功的消息,并转发到消息页面显示 - req.setAttribute("msg", "操作成功"); - String targetURL = "/common/msg.jsp"; - dispatch(targetURL, req, res); - } - - /** - * dispatch方法用于将请求转发到指定的目标页面。 - * @param targetURI 目标页面的URI - * @param request 请求对象 - * @param response 响应对象 - */ - public void dispatch(String targetURI, HttpServletRequest request, HttpServletResponse response) { - // 获取目标URI的RequestDispatcher - RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI); - try { - dispatch.forward(request, response); // 执行请求转发 - } catch (ServletException e) { - e.printStackTrace(); // 捕获并打印异常 - } catch (IOException e) { - e.printStackTrace(); // 捕获并打印异常 - } - } - - /** - * init方法用于初始化Servlet配置。 - * @param config Servlet配置对象 - */ - public void init(ServletConfig config) throws ServletException { - super.init(config); // 调用父类的初始化方法 - } - - /** - * destroy方法用于销毁Servlet实例。 - * 在Servlet销毁时清理资源,通常不需要在此类中做额外处理。 - */ - public void destroy() { - // 在此方法中可以释放一些资源,如数据库连接等 - } -} diff --git a/site/cart/mycart.jsp b/site/cart/mycart.jsp new file mode 100644 index 0000000..2438053 --- /dev/null +++ b/site/cart/mycart.jsp @@ -0,0 +1,157 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@ page isELIgnored="false" %> +<% +String path = request.getContextPath(); +%> + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+
+ +
+
+

鎴戠殑璐墿杞

+
+ + + + + + + + + + + + + + + + + + + + + + +
鍟嗗搧鍚嶇О璐拱浠锋牸璐拱鏁伴噺鎬婚噾棰鎿嶄綔
${item.value.goods.mingcheng}锟:${item.value.goods.tejia}${item.value.goods.tejia * item.value.goods_quantity} + +
+
+ 鎬婚噾棰濓細${sessionScope.cart.totalPrice} +      + +
+ + + + + + + + +
+ + + + + +
+
+
+
+ + + + +
 
+
+
+ + +
+ + diff --git a/site/default.jsp b/site/default.jsp new file mode 100644 index 0000000..97835ab --- /dev/null +++ b/site/default.jsp @@ -0,0 +1,23 @@ +<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + + + + + + + + + diff --git a/site/goods/goodsByCatelog.jsp b/site/goods/goodsByCatelog.jsp new file mode 100644 index 0000000..543ad48 --- /dev/null +++ b/site/goods/goodsByCatelog.jsp @@ -0,0 +1,93 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@ page isELIgnored="false" %> +<% +String path = request.getContextPath(); +%> + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+
+ +
+
+

鑿滃搧淇℃伅

+
+ + + + + + + + + +
+ + + + +
+

+ + +

${goods.mingcheng }
+

+
+
+
+
+
+ + + + + +
 
+
+
+ + +
+ + diff --git a/site/goods/goodsDetailQian.jsp b/site/goods/goodsDetailQian.jsp new file mode 100644 index 0000000..e301c0c --- /dev/null +++ b/site/goods/goodsDetailQian.jsp @@ -0,0 +1,110 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@ page isELIgnored="false" %> +<% +String path = request.getContextPath(); +%> + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+
+ +
+
+

鑿滃搧璇︾粏淇℃伅

+
+
+ + + + + + + + + + + + + + + + + + + +
鍟嗗搧缂栧彿锛${requestScope.goods.bianhao }
鍟嗗搧鍚嶇О锛${requestScope.goods.mingcheng }
鍟嗗搧鎻忚堪锛
浠锋牸锛${requestScope.goods.shichangjia }
+ 鏁伴噺锛 + + + +
+
+
+
+
+ + + + +
 
+
+
+ + +
+ + diff --git a/site/goods/goodsNew.jsp b/site/goods/goodsNew.jsp new file mode 100644 index 0000000..caac8d0 --- /dev/null +++ b/site/goods/goodsNew.jsp @@ -0,0 +1,93 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@ page isELIgnored="false" %> +<% +String path = request.getContextPath(); +%> + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+
+ +
+
+

鑿滃搧淇℃伅

+
+ + + + + + + + + +
+ + + + +
+

+ + +

${goods.mingcheng }
+

+
+
+
+
+
+ + + + + +
 
+
+
+ + +
+ + diff --git a/site/goods/goodsRes.jsp b/site/goods/goodsRes.jsp new file mode 100644 index 0000000..78a7944 --- /dev/null +++ b/site/goods/goodsRes.jsp @@ -0,0 +1,92 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@ page isELIgnored="false" %> +<% +String path = request.getContextPath(); +%> + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+
+ +
+
+

鑿滃搧淇℃伅

+
+ + + + + + + + + +
+ + + + +
+

+ + +

${goods.mingcheng }
+

+
+
+
+
+
+ + + + +
 
+
+
+ + +
+ + diff --git a/site/goods/goodsSea.jsp b/site/goods/goodsSea.jsp new file mode 100644 index 0000000..9ce52f6 --- /dev/null +++ b/site/goods/goodsSea.jsp @@ -0,0 +1,90 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@ page isELIgnored="false" %> +<% +String path = request.getContextPath(); +%> + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+
+ +
+
+ +
+
+ + + + + + + + + +
+ 鑿滃搧鍚嶇О锛 + + + +
+   +   +
+
+
+
+
+ + + + +
 
+
+
+ + +
+ + diff --git a/site/inc/daohang.jsp b/site/inc/daohang.jsp new file mode 100644 index 0000000..4710547 --- /dev/null +++ b/site/inc/daohang.jsp @@ -0,0 +1,81 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@ page isELIgnored="false" %> +<% +String path = request.getContextPath(); +%> + + + + + + + + + + + + + + + + + + + + + diff --git a/site/inc/left.jsp b/site/inc/left.jsp new file mode 100644 index 0000000..640fb46 --- /dev/null +++ b/site/inc/left.jsp @@ -0,0 +1,47 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@ page isELIgnored="false" %> + +<% +String path = request.getContextPath(); +%> + + + + + + + + + + + + + + + + + + diff --git a/site/index.jsp b/site/index.jsp new file mode 100644 index 0000000..8c0eae3 --- /dev/null +++ b/site/index.jsp @@ -0,0 +1,72 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<% +String path = request.getContextPath(); +%> + + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+
+ +
+
+

1111

+
+

Sed lacus. Donec lectus. Nullam prum. Proin imperdiet est. Phasellus dapibus semper urna. Pellentesque ornare,

+ +
+
+
+ + + + +
 
+
+
+ + +
+ + diff --git a/huifuAdd.jsp b/site/liuyan/liuyanAdd.jsp similarity index 59% rename from huifuAdd.jsp rename to site/liuyan/liuyanAdd.jsp index 4919a81..239ce5b 100644 --- a/huifuAdd.jsp +++ b/site/liuyan/liuyanAdd.jsp @@ -1,6 +1,4 @@ -<%@ page language="java" pageEncoding="UTF-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ page isELIgnored="false" %> <% @@ -10,6 +8,7 @@ String path = request.getContextPath(); + @@ -19,40 +18,39 @@ String path = request.getContextPath(); -
- - - - + +
  
+ + + - + diff --git a/site/liuyan/liuyanAll.jsp b/site/liuyan/liuyanAll.jsp new file mode 100644 index 0000000..36e603a --- /dev/null +++ b/site/liuyan/liuyanAll.jsp @@ -0,0 +1,108 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@ page isELIgnored="false" %> +<% +String path = request.getContextPath(); +%> + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+
+ +
+
+

  鐣欒█鏉挎ā鍧

+
+ +
+
+     + + ${liuyan.neirong} +
+
${liuyan.liuyanshi}
+
+
+
+
+
+ 鎴戣鐣欒█ +
+
+
+
+ + + + +
 
+
+
+ + +
+ + diff --git a/liuyanHuifu.jsp b/site/liuyan/liuyanDetail.jsp similarity index 58% rename from liuyanHuifu.jsp rename to site/liuyan/liuyanDetail.jsp index 9855dff..36fb9ef 100644 --- a/liuyanHuifu.jsp +++ b/site/liuyan/liuyanDetail.jsp @@ -1,6 +1,7 @@ -<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> +<%@ page language="java" pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@ page isELIgnored="false" %> -<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%> <% String path = request.getContextPath(); @@ -9,7 +10,6 @@ String path = request.getContextPath(); - @@ -19,41 +19,45 @@ String path = request.getContextPath(); - +
 
- 淇℃伅鍐呭锛 + 淇℃伅鍐呭锛 - +
  - "/> -   +    
- + + + + + + + + +
淇℃伅浜ゆ祦 
+ 淇℃伅鍐呭锛 + + ${requestScope.liuyan.neirong } +
+ 鍙戝竷鏃堕棿锛 + + ${requestScope.liuyan.liuyanshi } +
鍥炲鍐呭锛 - + ${requestScope.liuyan.huifu }
-   + 鍥炲鍐呭锛 - "/> -   -   + ${requestScope.liuyan.huifushi }
diff --git a/site/order/myorder.jsp b/site/order/myorder.jsp new file mode 100644 index 0000000..535a196 --- /dev/null +++ b/site/order/myorder.jsp @@ -0,0 +1,113 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@ page isELIgnored="false" %> +<% +String path = request.getContextPath(); +%> + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+
+ +
+
+

鎴戠殑璁㈠崟

+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
璁㈠崟缂栧彿锛${order.bianhao}
涓嬪崟鏃堕棿锛${order.shijian}
+ 璁㈠崟鐘舵侊細 + + 鏈彈鐞 + + + 宸插彈鐞 + +
鎺掗槦璁℃椂锛${order.huifu}
閫佽揣鍦板潃锛${order.songhuodizhi}
浠樻鏂瑰紡锛${order.fukuanfangshi}
鎬婚噾棰濓細${order.jine}  + 璁㈠崟鏄庣粏 +
+
+
+
+
+
+
+ + + + +
 
+
+
+ + +
+ + diff --git a/site/order/orderDetail.jsp b/site/order/orderDetail.jsp new file mode 100644 index 0000000..8b19261 --- /dev/null +++ b/site/order/orderDetail.jsp @@ -0,0 +1,180 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@ page isELIgnored="false" %> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + My JSP 'orderDetail.jsp' starting page + + + + + + + + + + + + + + + + + + + + + + + + +
鍟嗗搧鍚嶇О璐拱鏁伴噺璐拱浠锋牸
${orderItem.goods.mingcheng}${orderItem.goods_quantity}${orderItem.goods.tejia}
+ + diff --git a/site/order/orderQueren.jsp b/site/order/orderQueren.jsp new file mode 100644 index 0000000..b7a446b --- /dev/null +++ b/site/order/orderQueren.jsp @@ -0,0 +1,123 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@ page isELIgnored="false" %> +<% +String path = request.getContextPath(); +%> + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+
+ +
+
+

濉啓璁㈠崟

+
+ + + + + + + + + + + + + + + + + + +
+ 鏀惰揣浜哄笎鍙凤細 + + +
+ 鏀惰揣浜哄鍚嶏細 + + +
+ 閫佽揣鍦板潃锛 + + +
+ 浠樻鏂瑰紡锛 + + +
+ + + + + + + +
+ + + +
+ +
+
+
+ + + + +
 
+
+
+ + +
+ + diff --git a/site/order/orderSubmit.jsp b/site/order/orderSubmit.jsp new file mode 100644 index 0000000..90cd248 --- /dev/null +++ b/site/order/orderSubmit.jsp @@ -0,0 +1,94 @@ +<%@ page language="java" pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@ page isELIgnored="false" %> +<% +String path = request.getContextPath(); +%> + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+
+ +
+
+

+
+ + + + + + + + + + + + + + + + + + + + +
鎭枩鎮紝璁㈠崟鎻愪氦鎴愬姛锛
璁㈠崟缂栧彿锛${requestScope.order.bianhao }
鎬婚噾棰濓細${requestScope.order.jine }
涓嬪崟鏃ユ湡:${requestScope.order.shijian }
閫佽揣鍦板潃:${requestScope.order.songhuodizhi }
浠樻鏂瑰紡:${requestScope.order.fukuanfangshi }
+
+
+
+ + + + +
 
+
+
+ + +
+ + diff --git a/site/userlogin/userlogin.jsp b/site/userlogin/userlogin.jsp new file mode 100644 index 0000000..a965fac --- /dev/null +++ b/site/userlogin/userlogin.jsp @@ -0,0 +1,84 @@ +<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> +<% +String path = request.getContextPath(); +String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; +%> + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
璐﹀彿锛
瀵嗙爜锛
  + +   + + +
+
+ + diff --git a/site/userreg/userreg.jsp b/site/userreg/userreg.jsp new file mode 100644 index 0000000..98753b4 --- /dev/null +++ b/site/userreg/userreg.jsp @@ -0,0 +1,122 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<% +String path = request.getContextPath(); +%> + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+
+ +
+
+

  浼氬憳娉ㄥ唽

+
+
+ + + + + + + + + + + + + + + + + +
+ 璐﹀彿锛 + +   + +
+ 瀵嗙爜锛 + +   + +
+ 濮撳悕锛 + +   + +
+   + +   + + +
+
+
+
+
+ + + + +
 
+
+
+ + +
+ + diff --git a/sysPro.jsp b/sysPro.jsp deleted file mode 100644 index e69de29..0000000 diff --git a/updown/updown.jsp b/updown/updown.jsp new file mode 100644 index 0000000..17aaf14 --- /dev/null +++ b/updown/updown.jsp @@ -0,0 +1,49 @@ +<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> +<%@ page import="com.jspsmart.upload.*" %> +<% +String path = request.getContextPath(); +%> + + + + + + + + + + + + + <% + try + { + String fujianPath=request.getParameter("fujianPath");//鑾峰緱鍥剧墖璺緞 + String fujianYuashiMing=request.getParameter("fujianYuashiMing");//鑾峰緱鍥剧墖鐨勫師濮嬪悕 + fujianYuashiMing=java.net.URLDecoder.decode(fujianYuashiMing,"UTF-8");//鍥剧墖鍘熷鍚嶇殑缂栫爜鏂瑰紡 + System.out.println(fujianYuashiMing+fujianPath);//杈撳嚭鍥剧墖鐨勫師濮嬪悕鍜岃矾寰 + + SmartUpload su = new SmartUpload(); // 鏂板缓涓涓猄martUpload瀵硅薄 + + su.initialize(pageContext); // 鍒濆鍖 + + su.setContentDisposition(null); + // 璁惧畾contentDisposition涓簄ull浠ョ姝㈡祻瑙堝櫒鑷姩鎵撳紑鏂囦欢锛 + //淇濊瘉鐐瑰嚮閾炬帴鍚庢槸涓嬭浇鏂囦欢銆傝嫢涓嶈瀹氾紝鍒欎笅杞界殑鏂囦欢鎵╁睍鍚嶄负 + //doc鏃讹紝娴忚鍣ㄥ皢鑷姩鐢╳ord鎵撳紑瀹冦傛墿灞曞悕涓簆df鏃讹紝灏嗙敤acrobat鎵撳紑 + su.downloadFile(fujianPath, null, new String(fujianYuashiMing.getBytes(), "ISO8859-1")); // 涓嬭浇涓枃鏂囦欢 + out.clear(); + out=pageContext.pushBody(); + } + catch(Exception e) + {%> + + <%} + %> + + + + diff --git a/userDetail.jsp b/userDetail.jsp deleted file mode 100644 index 1ef9874..0000000 --- a/userDetail.jsp +++ /dev/null @@ -1,83 +0,0 @@ -<%@ page language="java" pageEncoding="UTF-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> -<%@ page isELIgnored="false" %> -<% -String path = request.getContextPath(); -%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  
搴忓彿璐﹀彿瀵 鐮濮撳悕鎿嶄綔
- ${ss.index+1} - - ${user.loginname} - - ${user.loginpw} - - ${user.name} - - -
- - - -     -
- - - - - - - - - - -
灞炴э細${xinyong.shuxing}
璇勪环鍐呭锛${xinyong.neirong}
璇勪环鏃堕棿锛${xinyong.shijian}
-
-
-
- - diff --git a/userMana.jsp b/userMana.jsp deleted file mode 100644 index 3a0e09a..0000000 --- a/userMana.jsp +++ /dev/null @@ -1,66 +0,0 @@ -<%@ page language="java" pageEncoding="UTF-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> -<%@ page isELIgnored="false" %> -<% -String path = request.getContextPath(); -%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  
搴忓彿璐﹀彿瀵 鐮濮撳悕鎿嶄綔
- ${ss.index+1} - - ${user.loginname} - - ${user.loginpw} - - ${user.name} - - -
- - diff --git a/userPw.jsp b/userPw.jsp deleted file mode 100644 index 994a83b..0000000 --- a/userPw.jsp +++ /dev/null @@ -1,96 +0,0 @@ -<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> -<%@ page isELIgnored="false" %> - -<% -String path = request.getContextPath(); -%> - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
瀵嗙爜淇敼
- 鐧诲綍鍚嶏細 - - - -
- 鍘熷瘑鐮侊細 - - -
- 鏂板瘑鐮侊細 - - -
-   - - -     - - -
-
- - diff --git a/user_servlet.java b/user_servlet.java deleted file mode 100644 index ec83748..0000000 --- a/user_servlet.java +++ /dev/null @@ -1,234 +0,0 @@ -package com.itbaizhan.action; - -import java.io.IOException; -import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import com.itbaizhan.dao.DB; -import com.itbaizhan.orm.Tuser; -import com.itbaizhan.service.liuService; - -public class user_servlet extends HttpServlet { - - /** - * service方法根据请求的类型(type)来决定调用哪个处理方法。 - * @param req HttpServletRequest对象,包含请求参数和数据 - * @param res HttpServletResponse对象,用于返回响应数据 - * @throws ServletException Servlet异常 - * @throws IOException I/O异常 - */ - public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - // 获取请求的type参数来判断要执行的操作 - String type = req.getParameter("type"); - - if (type.endsWith("userReg")) { - userReg(req, res); // 会员注册 - } - if (type.endsWith("userLogout")) { - userLogout(req, res); // 会员退出 - } - if (type.endsWith("userMana")) { - userMana(req, res); // 会员管理 - } - if (type.endsWith("userDel")) { - userDel(req, res); // 会员删除 - } - - if (type.endsWith("userDetail")) { - userDetail(req, res); // 会员详细信息 - } - } - - /** - * userReg方法用于会员注册。 - * 该方法获取用户提交的注册信息,检查账号是否已被占用,如果没有被占用则执行注册操作。 - * @param req HttpServletRequest对象 - * @param res HttpServletResponse对象 - */ - public void userReg(HttpServletRequest req, HttpServletResponse res) { - String id = String.valueOf(new Date().getTime()); // 使用当前时间戳作为用户ID - String loginname = req.getParameter("loginname"); // 获取用户名 - String loginpw = req.getParameter("loginpw"); // 获取密码 - String name = req.getParameter("name"); // 获取用户姓名 - String del = "no"; // 设置删除标志为"no"表示用户没有被删除 - - // 检查账号是否已经被占用 - String s = liuService.panduan_zhanghao(loginname); - if (s.equals("yizhan")) { - // 如果账号已经被占用,返回提示信息 - req.setAttribute("message", "账号已被占用,请输入其他账号"); - req.setAttribute("path", "site/userreg/userreg.jsp"); - String targetURL = "/common/success.jsp"; - dispatch(targetURL, req, res); - } else { - // 如果账号未被占用,则执行注册操作 - String sql = "insert into t_user values(?,?,?,?,?)"; // 插入新用户的SQL语句 - Object[] params = {id, loginname, loginpw, name, del}; // 设置SQL语句的参数 - DB mydb = new DB(); - mydb.doPstm(sql, params); // 执行插入操作 - mydb.closed(); // 关闭数据库连接 - - // 注册成功,返回成功页面 - req.setAttribute("message", "注册成功,请登录"); - req.setAttribute("path", "site/default.jsp"); - String targetURL = "/common/success.jsp"; - dispatch(targetURL, req, res); - } - } - - /** - * userLogout方法用于会员退出系统。 - * @param req HttpServletRequest对象 - * @param res HttpServletResponse对象 - * @throws ServletException Servlet异常 - * @throws IOException I/O异常 - */ - public void userLogout(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - HttpSession session = req.getSession(); // 获取当前会话 - session.setAttribute("userType", null); // 清除会话中的用户类型 - session.setAttribute("user", null); // 清除会话中的用户信息 - - // 提示用户退出成功 - req.setAttribute("message", "成功退出系统"); - req.setAttribute("path", "site/default.jsp"); - String targetURL = "/common/success.jsp"; - dispatch(targetURL, req, res); - } - - /** - * userMana方法用于会员管理,查询所有未删除的会员。 - * @param req HttpServletRequest对象 - * @param res HttpServletResponse对象 - * @throws ServletException Servlet异常 - * @throws IOException I/O异常 - */ - public void userMana(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - List userList = new ArrayList(); // 用于保存用户信息的列表 - String sql = "select * from t_user where del='no'"; // 查询所有未被删除的用户 - Object[] params = {}; // SQL查询没有参数 - DB mydb = new DB(); - try { - mydb.doPstm(sql, params); // 执行查询操作 - ResultSet rs = mydb.getRs(); // 获取查询结果集 - while (rs.next()) { - Tuser user = new Tuser(); // 创建Tuser对象来封装每个用户的数据 - user.setId(rs.getString("id")); - user.setLoginname(rs.getString("loginname")); - user.setLoginpw(rs.getString("loginpw")); - user.setName(rs.getString("name")); - userList.add(user); // 将用户添加到列表中 - } - rs.close(); // 关闭结果集 - } catch (Exception e) { - e.printStackTrace(); // 捕获异常并打印堆栈信息 - } - mydb.closed(); // 关闭数据库连接 - - // 将用户列表传递给JSP页面 - req.setAttribute("userList", userList); - req.getRequestDispatcher("admin/user/userMana.jsp").forward(req, res); - } - - /** - * userDel方法用于删除指定ID的用户。 - * 实际上是将用户的`del`字段更新为"yes"表示删除。 - * @param req HttpServletRequest对象 - * @param res HttpServletResponse对象 - * @throws ServletException Servlet异常 - * @throws IOException I/O异常 - */ - public void userDel(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String id = req.getParameter("id"); // 获取要删除用户的ID - String sql = "update t_user set del='yes' where id=?"; // 更新SQL语句,将del字段设为"yes" - Object[] params = {id}; // 设置参数为用户ID - DB mydb = new DB(); - mydb.doPstm(sql, params); // 执行更新操作 - mydb.closed(); // 关闭数据库连接 - - // 返回删除成功的消息 - req.setAttribute("msg", "用户信息删除完毕"); - String targetURL = "/common/msg.jsp"; - dispatch(targetURL, req, res); - } - - /** - * userDetail方法用于查看指定用户的详细信息。 - * @param req HttpServletRequest对象 - * @param res HttpServletResponse对象 - * @throws ServletException Servlet异常 - * @throws IOException I/O异常 - */ - public void userDetail(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String id = req.getParameter("id"); // 获取用户ID - List userList = new ArrayList(); // 用于保存用户信息的列表 - String sql = "select * from t_user where id=?"; // 查询指定ID的用户 - Object[] params = {id}; // 设置参数为用户ID - DB mydb = new DB(); - try { - mydb.doPstm(sql, params); // 执行查询操作 - ResultSet rs = mydb.getRs(); // 获取查询结果集 - while (rs.next()) { - Tuser user = new Tuser(); // 创建Tuser对象来封装用户数据 - user.setId(rs.getString("id")); - user.setLoginname(rs.getString("loginname")); - user.setLoginpw(rs.getString("loginpw")); - user.setName(rs.getString("name")); - userList.add(user); // 将用户添加到列表中 - } - rs.close(); // 关闭结果集 - } catch (Exception e) { - e.printStackTrace(); // 捕获异常并打印堆栈信息 - } - mydb.closed(); // 关闭数据库连接 - - // 获取用户信用信息,并将数据传递给JSP页面 - req.setAttribute("userList", userList); - req.setAttribute("xinyongList", liuService.getxinyongList(id)); - req.getRequestDispatcher("admin/user/userDetail.jsp").forward(req, res); - } - - /** - * dispatch方法用于将请求转发到指定的目标页面。 - * @param targetURI 目标页面的URI - * @param request 请求对象 - * @param response 响应对象 - */ - public void dispatch(String targetURI, HttpServletRequest request, HttpServletResponse response) { - // 获取目标URI的RequestDispatcher - RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI); // 获取请求转发器 - try { - dispatch.forward(request, response); // 执行请求转发 - return; - } catch (ServletException e) { - e.printStackTrace(); // 捕获ServletException异常并打印堆栈信息 - } catch (IOException e) { - e.printStackTrace(); // 捕获IOException异常并打印堆栈信息 - } - } - - /** - * init方法在Servlet初始化时调用,通常用于一些初始化操作。 - * @param config ServletConfig对象,包含Servlet的配置参数 - * @throws ServletException Servlet初始化异常 - */ - public void init(ServletConfig config) throws ServletException { - super.init(config); // 调用父类的init方法进行初始化 - } - - /** - * destroy方法在Servlet销毁时调用,用于清理资源。 - */ - public void destroy() { - // 在此方法中执行清理工作,例如关闭数据库连接等资源释放操作。 - } -} diff --git a/xinyongAdd.jsp b/xinyongAdd.jsp deleted file mode 100644 index 499b7b6..0000000 --- a/xinyongAdd.jsp +++ /dev/null @@ -1,83 +0,0 @@ -<%@page import="java.text.SimpleDateFormat"%> -<%@page import="java.util.Date"%> -<%@ page language="java" pageEncoding="UTF-8"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> -<%@ page isELIgnored="false"%> - -<% -String path = request.getContextPath(); -%> - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
  
- 璇勪环灞炴э細 - - 濂借瘎 -      - 宸瘎 -
- 璇勪环鍐呭锛 - - -
- 璇勪环鏃堕棿锛 - - "/> - -
-   - - "/> -   -   -
-
- - diff --git a/xinyong_servlet.java b/xinyong_servlet.java deleted file mode 100644 index cb14738..0000000 --- a/xinyong_servlet.java +++ /dev/null @@ -1,160 +0,0 @@ -package com.itbaizhan.action; - -import java.io.IOException; -import java.sql.ResultSet; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.itbaizhan.dao.DB; -import com.itbaizhan.orm.Txinyong; - -public class xinyong_servlet extends HttpServlet { - - /** - * service方法,根据请求的type参数决定调用哪个功能方法。 - * @param req HttpServletRequest 请求对象 - * @param res HttpServletResponse 响应对象 - * @throws ServletException Servlet异常 - * @throws IOException IO异常 - */ - public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String type = req.getParameter("type"); // 获取请求参数 type - - if (type.endsWith("xinyongAdd")) { - xinyongAdd(req, res); // 调用信用添加方法 - } - if (type.endsWith("xinyongMana")) { - xinyongMana(req, res); // 调用信用管理方法 - } - if (type.endsWith("xinyongDel")) { - xinyongDel(req, res); // 调用信用删除方法 - } - } - - /** - * 处理信用添加功能。 - * @param req HttpServletRequest 请求对象 - * @param res HttpServletResponse 响应对象 - */ - public void xinyongAdd(HttpServletRequest req, HttpServletResponse res) { - String id = String.valueOf(new Date().getTime()); // 使用当前时间戳生成唯一ID - String shuxing = req.getParameter("shuxing").trim(); // 获取信用属性 - String neirong = req.getParameter("neirong").trim(); // 获取信用内容 - String shijian = req.getParameter("shijian").trim(); // 获取时间 - String user_id = req.getParameter("user_id").trim(); // 获取用户ID - - // 插入SQL语句 - String sql = "insert into t_xinyong(id, shuxing, neirong, shijian, user_id) values(?,?,?,?,?)"; - Object[] params = {id, shuxing, neirong, shijian, user_id}; - DB mydb = new DB(); - mydb.doPstm(sql, params); // 执行插入操作 - mydb.closed(); // 关闭数据库连接 - - req.setAttribute("msg", "操作成功"); // 设置提示消息 - String targetURL = "/common/msg.jsp"; // 跳转到提示页面 - dispatch(targetURL, req, res); // 执行请求转发 - } - - /** - * 处理信用管理功能。 - * @param req HttpServletRequest 请求对象 - * @param res HttpServletResponse 响应对象 - * @throws ServletException Servlet异常 - * @throws IOException IO异常 - */ - public void xinyongMana(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String user_id = req.getParameter("user_id").trim(); // 获取用户ID - - List xinyongList = new ArrayList(); // 用于存储信用记录的列表 - String sql = "select * from t_xinyong where user_id=?"; - Object[] params = {user_id}; - DB mydb = new DB(); - try { - mydb.doPstm(sql, params); // 执行查询操作 - ResultSet rs = mydb.getRs(); // 获取查询结果集 - while (rs.next()) { - Txinyong xinyong = new Txinyong(); // 创建信用对象 - - // 设置信用对象的属性 - xinyong.setId(rs.getString("id")); - xinyong.setShuxing(rs.getString("shuxing")); - xinyong.setNeirong(rs.getString("neirong")); - xinyong.setShijian(rs.getString("shijian")); - xinyong.setUser_id(rs.getString("user_id")); - - xinyongList.add(xinyong); // 将信用对象添加到列表中 - } - rs.close(); // 关闭结果集 - } catch (Exception e) { - e.printStackTrace(); // 捕获异常并打印堆栈信息 - } - mydb.closed(); // 关闭数据库连接 - - req.setAttribute("xinyongList", xinyongList); // 将信用列表传递到请求中 - req.getRequestDispatcher("admin/xinyong/xinyongMana.jsp").forward(req, res); // 转发请求到管理页面 - } - - /** - * 处理信用删除功能。 - * @param req HttpServletRequest 请求对象 - * @param res HttpServletResponse 响应对象 - * @throws ServletException Servlet异常 - * @throws IOException IO异常 - */ - public void xinyongDel(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { - String id = req.getParameter("id").trim(); // 获取信用记录ID - - String sql = "delete from t_xinyong where id=?"; - Object[] params = {id}; - DB mydb = new DB(); - mydb.doPstm(sql, params); // 执行删除操作 - mydb.closed(); // 关闭数据库连接 - - req.setAttribute("msg", "操作成功"); // 设置提示消息 - String targetURL = "/common/msg.jsp"; // 跳转到提示页面 - dispatch(targetURL, req, res); // 执行请求转发 - } - - /** - * 执行请求转发到指定页面。 - * @param targetURI 目标页面的URI - * @param request HttpServletRequest 请求对象 - * @param response HttpServletResponse 响应对象 - */ - public void dispatch(String targetURI, HttpServletRequest request, HttpServletResponse response) { - RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI); // 获取请求转发器 - try { - dispatch.forward(request, response); // 执行转发 - return; - } catch (ServletException e) { - e.printStackTrace(); // 捕获并打印ServletException异常 - } catch (IOException e) { - e.printStackTrace(); // 捕获并打印IOException异常 - } - } - - /** - * Servlet初始化方法,在Servlet实例化时调用。 - * @param config ServletConfig对象,包含Servlet配置参数 - * @throws ServletException Servlet异常 - */ - public void init(ServletConfig config) throws ServletException { - super.init(config); // 调用父类的init方法进行初始化 - } - - /** - * Servlet销毁方法,在Servlet销毁时调用。 - * 用于释放资源,如关闭数据库连接等。 - */ - public void destroy() { - // 在此方法中执行清理工作,例如释放数据库连接等 - } -}