javaweb练习分析——5

在完成对单表的增删改查操作后,就要实现项目中的业务逻辑,比如登录操作、还有目前这个项目中的房产之间的买卖业务逻辑,需要不同角色之间共同完成功能,将多表联系起来。
以顾客购买房产为例,第一步首先要将在售的房产呈现出来,之后就是顾客可以点击地址查看详细信息,然后顾客点击交易可以购买房产,最后点击交易后实现房产状态的改变以及房产顾客的更新。
顾客浏览房产(查询在售)->点击查看详细信息(单一信息查询后将信息呈现在页面)->在页面增加交易按钮->点击后可将状态传递给后端(实现更新)->session中获取顾客信息更改房产顾客

public void purchase(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String id = req.getParameter("houseId");
        String status = req.getParameter("status");
        HttpSession session = req.getSession();
        String name = (String) session.getAttribute("username");
        Customer customer = customerService.selectByName(name);
        String Cus = customer.getCustomerId();
        House house = new House();
        house.setCustomer(Cus);
        house.setHouseId(id);
        house.setStatus(status);
        houseService.purchase(house);
        req.getRequestDispatcher("/customer.html").forward(req, resp);
    }
posted @ 2024-12-21 21:16  Look_Back  阅读(5)  评论(0)    收藏  举报