add history login and not divide pages
This commit is contained in:
parent
5ea1a65e0c
commit
a2b0187f2e
@ -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<Record> records = (List<Record>) recordDao.findHistoryRecord(workerUser.getUsername());
|
||||
|
||||
// 将订单数据添加到Model中,以便在JSP页面中使用
|
||||
model.addAttribute("records", records);
|
||||
|
||||
// 返回到展示订单列表的JSP页面
|
||||
return "/worker/worker_history_loginList";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user