add histroy list

add doing list
This commit is contained in:
sobear 2024-05-13 21:33:36 +08:00
parent 14774b67c7
commit 7083a0cbb0
2 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,45 @@
package cn.edu.cqwu.repair.controller.worker;
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 WorkerHistoryListController extends HttpServlet{
private OrderDao orderDao;
private WorkerDao workerDao;
@Autowired
public WorkerHistoryListController(WorkerDao workerDao, OrderDao orderDao) {
this.workerDao = workerDao;
this.orderDao = orderDao;
}
@GetMapping("/workerHistoryList.do")
public String getOrders(Model model, HttpSession session,
HttpServletRequest request){
// 获取Session对象
session = request.getSession();
// 从Session中获取ID数据
Worker workerUser = (Worker) session.getAttribute("workerUser");
// 调用DAO的方法来获取数据库中的历史订单数据
List<Order> orders = (List<Order>) orderDao.findHistoryList(workerUser.getUserid());
// 将订单数据添加到Model中以便在JSP页面中使用
model.addAttribute("orders", orders);
// 返回到展示订单列表的JSP页面
return "/worker/worker_history_fixList";
}
}

View File

@ -0,0 +1,43 @@
package cn.edu.cqwu.repair.controller.worker;
import cn.edu.cqwu.repair.dao.OrderDao;
import javax.servlet.http.*;
import cn.edu.cqwu.repair.util.Encrypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Controller
public class WorkerOrderStatusController {
private OrderDao orderDao;
@Autowired
public WorkerOrderStatusController(OrderDao orderDao){
this.orderDao = orderDao;
}
@RequestMapping("/updateOrderStatus")
public String updateOrderStatus(HttpServletRequest request,Model model) {
int orderId = Integer.parseInt(request.getParameter("orderId"));
if(orderDao.statusModify(orderId) != 0){
model.addAttribute("workerListStatusMes", "* 状态更新成功!");
}else {
model.addAttribute("workerListStatusMes", "* 状态更新失败!");
}
return "forward:/workerFixList.do";
}
}