package cn.itcast.estore.web.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.itcast.estore.domain.User;
import cn.itcast.estore.service.OrderService;
public class CancelOderByIdServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//1.获取参数订单id
String id = request.getParameter("id");
//获取当前登录用户
User user = (User) request.getSession().getAttribute("existUser");
//2.调用service中方法cancelOderById()
OrderService service = new OrderService();
service.deleteOrderById(user,id);
//3.转发到订单查询servlet
response.sendRedirect(request.getContextPath()+"/showOrder");
return;
}
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}