Update UpdatePrepServlet.java

pull/1/head
pght2c95q 8 months ago
parent 3cf63e591f
commit c1eb3140ef

@ -22,27 +22,38 @@ public class UpdatePrepServlet extends HttpServlet {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* @see HttpServlet#HttpServlet() * HttpServlet
*/ */
public UpdatePrepServlet() { public UpdatePrepServlet() {
super(); super();
// TODO Auto-generated constructor stub // 构造函数中的代码,通常不需要自定义操作,因为父类已经处理
} }
/** /**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) * GET
* GETServlet
* @param request HttpServletRequest
* @param response HttpServletResponse
* @throws ServletException Servlet
* @throws IOException IO
*/ */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 从请求中获取订单ID和临时变量temp参数并转换为Integer类型
Integer prepId = Integer.valueOf(request.getParameter("prepId")); Integer prepId = Integer.valueOf(request.getParameter("prepId"));
Integer temp = Integer.valueOf(request.getParameter("temp")); Integer temp = Integer.valueOf(request.getParameter("temp"));
// 创建PrepService的实现类对象用于访问订单相关的业务逻辑
PrepService prepService = new PrepServiceImpl(); PrepService prepService = new PrepServiceImpl();
// 根据订单ID获取订单对象
Prep prep = prepService.getById(prepId); Prep prep = prepService.getById(prepId);
// 付款业务 // 如果temp参数为1表示进行付款业务
if(temp == 1) { if(temp == 1) {
// 设置订单的付款状态为已付款
prep.setWay(true); prep.setWay(true);
// 更新订单对象到数据库
int recordNumber = prepService.update(prep); int recordNumber = prepService.update(prep);
// 根据更新结果设置消息,并转发到我的订单页面
if(recordNumber == 1) { if(recordNumber == 1) {
request.setAttribute("msg", "付款成功!"); request.setAttribute("msg", "付款成功!");
} else { } else {
@ -51,20 +62,24 @@ public class UpdatePrepServlet extends HttpServlet {
request.getRequestDispatcher("MyPrepServlet").forward(request, response); request.getRequestDispatcher("MyPrepServlet").forward(request, response);
} }
// 改签业务(先将prepId转发到ChangePrepServlet) // 如果temp参数为2表示进行改签业务先将prepId转发到ChangePrepServlet
if(temp == 2) { if(temp == 2) {
request.setAttribute("prepId", prepId); request.setAttribute("prepId", prepId);
request.getRequestDispatcher("ChangePrepServlet").forward(request, response); request.getRequestDispatcher("ChangePrepServlet").forward(request, response);
} }
} }
/** /**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) * POST
* POST
* @param request HttpServletRequest
* @param response HttpServletResponse
* @throws ServletException Servlet
* @throws IOException IO
*/ */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub // TODO Auto-generated method stub
doGet(request, response); doGet(request, response);
} }

Loading…
Cancel
Save