diff --git a/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerHistoryLoginController.java b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerHistoryLoginController.java new file mode 100644 index 0000000..e8a9928 --- /dev/null +++ b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerHistoryLoginController.java @@ -0,0 +1,46 @@ +package cn.edu.cqwu.repair.controller.worker; + +import cn.edu.cqwu.repair.dao.RecordDao; +import cn.edu.cqwu.repair.dao.WorkerDao; +import org.springframework.stereotype.Controller; + + +import cn.edu.cqwu.repair.dao.OrderDao; + +import javax.servlet.http.*; +import cn.edu.cqwu.repair.entity.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +@Controller +public class WorkerHistoryLoginController extends HttpServlet{ + private final RecordDao recordDao; + private final WorkerDao workerDao; + @Autowired + public WorkerHistoryLoginController(WorkerDao workerDao, RecordDao recordDao) { + this.workerDao = workerDao; + this.recordDao = recordDao; + } + @GetMapping("/workerHistoryLogin.do") + public String getOrders(Model model, HttpSession session, + HttpServletRequest request){ + // 获取Session对象 + session = request.getSession(); + + // 从Session中获取ID数据 + Worker workerUser = (Worker) session.getAttribute("workerUser"); + // 调用DAO的方法来获取数据库中的历史登录数据 + List records = (List) recordDao.findHistoryRecord(workerUser.getUsername()); + + // 将订单数据添加到Model中,以便在JSP页面中使用 + model.addAttribute("records", records); + + // 返回到展示订单列表的JSP页面 + return "/worker/worker_history_loginList"; + } + +}