From 2943a47a8da61a3f486efab44b5438082efbc139 Mon Sep 17 00:00:00 2001 From: sobear <410731299@qq.com> Date: Sun, 12 May 2024 23:35:45 +0800 Subject: [PATCH] add worker list --- .idea/webContexts.xml | 1 + .../worker/WorkerFixListController.java | 52 +++++++++++++++++++ .../worker/WorkerLoginController.java | 2 +- .../java/cn/edu/cqwu/repair/dao/OrderDao.java | 4 +- .../cqwu/repair/dao/impl/OrderDaoImpl.java | 16 ++++++ .../cqwu/repair/dao/impl/WorkerDaoImpl.java | 2 +- src/main/webapp/includes/menu.jsp | 12 ++--- .../webapp/worker/worker_center_index.jsp | 38 ++------------ src/main/webapp/worker/worker_fixList.jsp | 46 ++++++++++++++++ .../webapp/worker/worker_history_fixList.jsp | 16 ++++++ .../worker/worker_history_loginList.jsp | 16 ++++++ src/main/webapp/worker/worker_modify.jsp | 16 ++++++ 12 files changed, 177 insertions(+), 44 deletions(-) create mode 100644 src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerFixListController.java create mode 100644 src/main/webapp/worker/worker_fixList.jsp create mode 100644 src/main/webapp/worker/worker_history_fixList.jsp create mode 100644 src/main/webapp/worker/worker_history_loginList.jsp create mode 100644 src/main/webapp/worker/worker_modify.jsp diff --git a/.idea/webContexts.xml b/.idea/webContexts.xml index 0aa5ca8..847b281 100644 --- a/.idea/webContexts.xml +++ b/.idea/webContexts.xml @@ -4,6 +4,7 @@ + diff --git a/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerFixListController.java b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerFixListController.java new file mode 100644 index 0000000..92a73ea --- /dev/null +++ b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerFixListController.java @@ -0,0 +1,52 @@ +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 cn.edu.cqwu.repair.service.RecordService; +import cn.edu.cqwu.repair.util.Encrypt; +import cn.edu.cqwu.repair.util.Verify; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import java.util.List;import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + + + +@Controller +public class WorkerFixListController extends HttpServlet{ + private OrderDao orderDao; + private WorkerDao workerDao; + @Autowired + public WorkerFixListController(WorkerDao workerDao, OrderDao orderDao) { + this.workerDao = workerDao; + this.orderDao = orderDao; + } + + @GetMapping("/workerFixList.do") + public String getOrders(Model model, HttpSession session, + HttpServletRequest request){ + // 获取Session对象 + session = request.getSession(); + + // 从Session中获取ID数据 + Worker workerUser = (Worker) session.getAttribute("workerUser"); + // 调用DAO的方法来获取数据库中的订单数据 + List orders = (List) orderDao.findByWorkerId(workerUser.getUserid()); + + // 将订单数据添加到Model中,以便在JSP页面中使用 + model.addAttribute("orders", orders); + + // 返回到展示订单列表的JSP页面 + return "/worker/worker_fixList"; + } +} diff --git a/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerLoginController.java b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerLoginController.java index 3479f52..da63b64 100644 --- a/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerLoginController.java +++ b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerLoginController.java @@ -51,7 +51,7 @@ public class WorkerLoginController { session.setAttribute("workerUser", user); return "redirect:/worker/worker_center_index.jsp"; } else { - model.addAttribute("adminLoginMess", "* 登录异常!"); + model.addAttribute("workerLoginMess", "* 登录异常!"); return "/worker_login"; } } diff --git a/src/main/java/cn/edu/cqwu/repair/dao/OrderDao.java b/src/main/java/cn/edu/cqwu/repair/dao/OrderDao.java index cf7fdb9..bfa628d 100644 --- a/src/main/java/cn/edu/cqwu/repair/dao/OrderDao.java +++ b/src/main/java/cn/edu/cqwu/repair/dao/OrderDao.java @@ -1,11 +1,13 @@ package cn.edu.cqwu.repair.dao; -import cn.edu.cqwu.repair.entity.AdminUser; import cn.edu.cqwu.repair.entity.Order; +import java.util.ArrayList; + public interface OrderDao { int add(Order order); + ArrayList findByWorkerId(int workerId); } diff --git a/src/main/java/cn/edu/cqwu/repair/dao/impl/OrderDaoImpl.java b/src/main/java/cn/edu/cqwu/repair/dao/impl/OrderDaoImpl.java index 7792022..496830a 100644 --- a/src/main/java/cn/edu/cqwu/repair/dao/impl/OrderDaoImpl.java +++ b/src/main/java/cn/edu/cqwu/repair/dao/impl/OrderDaoImpl.java @@ -3,18 +3,34 @@ package cn.edu.cqwu.repair.dao.impl; import cn.edu.cqwu.repair.dao.OrderDao; import cn.edu.cqwu.repair.db.ConnectionFactory; import cn.edu.cqwu.repair.entity.Order; +import cn.edu.cqwu.repair.entity.Worker; import cn.edu.cqwu.repair.entity.mapper.DeviceMapper; import cn.edu.cqwu.repair.entity.mapper.OrderMapper; +import cn.edu.cqwu.repair.entity.mapper.WorkerMapper; +import com.mybatisflex.core.query.QueryWrapper; import org.springframework.stereotype.Component; +import java.util.ArrayList; + +import static cn.edu.cqwu.repair.entity.table.WorkerTableDef.WORKER; +import static cn.edu.cqwu.repair.entity.table.OrderTableDef.ORDER; + @Component public class OrderDaoImpl implements OrderDao { private static final OrderMapper mapper = ConnectionFactory.getMapper(OrderMapper.class); + @Override public int add(Order order) { return mapper.insert(order); } + + @Override + public ArrayList findByWorkerId(int workerId){ + QueryWrapper qw = new QueryWrapper(); + qw.select(ORDER.ALL_COLUMNS).where(ORDER.WORKER_ID.eq(workerId)); + return (ArrayList) mapper.selectListByQuery(qw); + } } diff --git a/src/main/java/cn/edu/cqwu/repair/dao/impl/WorkerDaoImpl.java b/src/main/java/cn/edu/cqwu/repair/dao/impl/WorkerDaoImpl.java index c12b51f..9569d4e 100644 --- a/src/main/java/cn/edu/cqwu/repair/dao/impl/WorkerDaoImpl.java +++ b/src/main/java/cn/edu/cqwu/repair/dao/impl/WorkerDaoImpl.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Component; import java.util.ArrayList; -import static cn.edu.cqwu.repair.entity.table.StuTableDef.STU; + import static cn.edu.cqwu.repair.entity.table.WorkerTableDef.WORKER; @Component public class WorkerDaoImpl implements WorkerDao { diff --git a/src/main/webapp/includes/menu.jsp b/src/main/webapp/includes/menu.jsp index b8ad27d..4d0717b 100644 --- a/src/main/webapp/includes/menu.jsp +++ b/src/main/webapp/includes/menu.jsp @@ -64,20 +64,20 @@ - + >> 个人中心 - + >> 维修列表 - + >> 历史维修记录 - + >> 历史登录记录 - - >> 个人中心 + + >> 修改用户信息 diff --git a/src/main/webapp/worker/worker_center_index.jsp b/src/main/webapp/worker/worker_center_index.jsp index e08a07d..aae6841 100644 --- a/src/main/webapp/worker/worker_center_index.jsp +++ b/src/main/webapp/worker/worker_center_index.jsp @@ -36,42 +36,10 @@ - 维修管理系统 + 工人个人中心 - - - - - - >> 主页 - - - - - >> 个人中心 - - - - - >> 已接任务 - - - - - >> 历史任务 - - - - - - - >> 主页 - - - - - + <%@ include file="../includes/menu.jsp" %> @@ -79,7 +47,6 @@ - 工人个人中心 @@ -104,5 +71,6 @@ +<%@ include file="../includes/footer.jsp" %>