package web.UserRelated;


import pojo.ParkingSpot;
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/ParkInfo")
public class ParkServlet extends HttpServlet {
    UserService service = new UserService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        int parking_spot_id= Integer.parseInt(req.getParameter("parking_spot_id"));
        List<ParkingSpot> parklist=null;
        try {
            parklist=service.selectParkByParkId(parking_spot_id);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        req.setAttribute("parklist",parklist);
        req.getRequestDispatcher("/main/UserToInfo/parkInfo.jsp?").forward(req, resp);
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}


