package web.UserRelated;


import pojo.Vehicle;
import service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(urlPatterns = "/main/admin/CarInfo")
public class CarServlet extends HttpServlet {
    UserService service = new UserService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        int user_id= Integer.parseInt(req.getParameter("user_id"));
        List<Vehicle> carlist=null;
        try {
            carlist=service.selectCarByUserId(user_id);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        req.setAttribute("carlist",carlist);
        req.getRequestDispatcher("/main/UserToInfo/CarInfo.jsp?").forward(req, resp);
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}


