add worker list

This commit is contained in:
sobear 2024-05-12 23:35:45 +08:00
parent d8ce35567e
commit 2943a47a8d
12 changed files with 177 additions and 44 deletions

View File

@ -4,6 +4,7 @@
<option name="state"> <option name="state">
<map> <map>
<entry key="file://$PROJECT_DIR$/src/main/webapp/student/register.jsp" value="file://$PROJECT_DIR$/src/main/webapp/student" /> <entry key="file://$PROJECT_DIR$/src/main/webapp/student/register.jsp" value="file://$PROJECT_DIR$/src/main/webapp/student" />
<entry key="file://$PROJECT_DIR$/src/main/webapp/worker/worker_center_index.jsp" value="file://$PROJECT_DIR$/src/main/webapp/worker" />
</map> </map>
</option> </option>
</component> </component>

View File

@ -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<Order> orders = (List<Order>) orderDao.findByWorkerId(workerUser.getUserid());
// 将订单数据添加到Model中以便在JSP页面中使用
model.addAttribute("orders", orders);
// 返回到展示订单列表的JSP页面
return "/worker/worker_fixList";
}
}

View File

@ -51,7 +51,7 @@ public class WorkerLoginController {
session.setAttribute("workerUser", user); session.setAttribute("workerUser", user);
return "redirect:/worker/worker_center_index.jsp"; return "redirect:/worker/worker_center_index.jsp";
} else { } else {
model.addAttribute("adminLoginMess", "* 登录异常!"); model.addAttribute("workerLoginMess", "* 登录异常!");
return "/worker_login"; return "/worker_login";
} }
} }

View File

@ -1,11 +1,13 @@
package cn.edu.cqwu.repair.dao; package cn.edu.cqwu.repair.dao;
import cn.edu.cqwu.repair.entity.AdminUser;
import cn.edu.cqwu.repair.entity.Order; import cn.edu.cqwu.repair.entity.Order;
import java.util.ArrayList;
public interface OrderDao { public interface OrderDao {
int add(Order order); int add(Order order);
ArrayList<Order> findByWorkerId(int workerId);
} }

View File

@ -3,18 +3,34 @@ package cn.edu.cqwu.repair.dao.impl;
import cn.edu.cqwu.repair.dao.OrderDao; import cn.edu.cqwu.repair.dao.OrderDao;
import cn.edu.cqwu.repair.db.ConnectionFactory; import cn.edu.cqwu.repair.db.ConnectionFactory;
import cn.edu.cqwu.repair.entity.Order; 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.DeviceMapper;
import cn.edu.cqwu.repair.entity.mapper.OrderMapper; 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 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 @Component
public class OrderDaoImpl implements OrderDao { public class OrderDaoImpl implements OrderDao {
private static final OrderMapper mapper = ConnectionFactory.getMapper(OrderMapper.class); private static final OrderMapper mapper = ConnectionFactory.getMapper(OrderMapper.class);
@Override @Override
public int add(Order order) { public int add(Order order) {
return mapper.insert(order); return mapper.insert(order);
} }
@Override
public ArrayList<Order> findByWorkerId(int workerId){
QueryWrapper qw = new QueryWrapper();
qw.select(ORDER.ALL_COLUMNS).where(ORDER.WORKER_ID.eq(workerId));
return (ArrayList<Order>) mapper.selectListByQuery(qw);
}
} }

View File

@ -12,7 +12,7 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import static cn.edu.cqwu.repair.entity.table.StuTableDef.STU;
import static cn.edu.cqwu.repair.entity.table.WorkerTableDef.WORKER; import static cn.edu.cqwu.repair.entity.table.WorkerTableDef.WORKER;
@Component @Component
public class WorkerDaoImpl implements WorkerDao { public class WorkerDaoImpl implements WorkerDao {

View File

@ -64,20 +64,20 @@
</c:when> </c:when>
<c:when test="${not empty sessionScope.workerUser}"> <c:when test="${not empty sessionScope.workerUser}">
<li class="nav-item"> <li class="nav-item">
<a href="${webroot}/admin/state.jsp" class="nav-link link-body-emphasis" aria-current="page"> <a href="${webroot}/worker/worker_center_index.jsp" class="nav-link link-body-emphasis" aria-current="page">
>> 个人中心 >> 个人中心
</a> </a>
<a href="${webroot}/admin/state.jsp" class="nav-link link-body-emphasis" aria-current="page"> <a href="${webroot}/worker/worker_fixList.jsp" class="nav-link link-body-emphasis" aria-current="page">
>> 维修列表 >> 维修列表
</a> </a>
<a href="${webroot}/admin/state.jsp" class="nav-link link-body-emphasis" aria-current="page"> <a href="${webroot}/worker/worker_history_fixList.jsp" class="nav-link link-body-emphasis" aria-current="page">
>> 历史维修记录 >> 历史维修记录
</a> </a>
<a href="${webroot}/admin/state.jsp" class="nav-link link-body-emphasis" aria-current="page"> <a href="${webroot}/worker/worker_history_loginList.jsp" class="nav-link link-body-emphasis" aria-current="page">
>> 历史登录记录 >> 历史登录记录
</a> </a>
<a href="${webroot}/admin/state.jsp" class="nav-link link-body-emphasis" aria-current="page"> <a href="${webroot}/worker/worker_modify.jsp" class="nav-link link-body-emphasis" aria-current="page">
>> 个人中心 >> 修改用户信息
</a> </a>
</li> </li>
</c:when> </c:when>

View File

@ -36,42 +36,10 @@
<a href="${webroot}/" <a href="${webroot}/"
class="d-flex align-items-center mb-3 mb-md-0 me-md-auto link-body-emphasis text-decoration-none"> class="d-flex align-items-center mb-3 mb-md-0 me-md-auto link-body-emphasis text-decoration-none">
<img src="${webroot}/images/logo.jpg" alt="" width="32" height="32" class="rounded-circle me-2"> <img src="${webroot}/images/logo.jpg" alt="" width="32" height="32" class="rounded-circle me-2">
<span class="fs-4">维修管理系统</span> <span class="fs-4">工人个人中心</span>
</a> </a>
<hr> <hr>
<ul class="nav nav-pills flex-column mb-auto"> <%@ include file="../includes/menu.jsp" %>
<c:choose>
<c:when test="${not empty sessionScope.username}">
<li class="nav-item">
<a href="${webroot}/stu/notice.jsp" class="nav-link link-body-emphasis" aria-current="page">
>> 主页
</a>
</li>
<li class="nav-item">
<a href="${webroot}/xx.jsp" class="nav-link link-body-emphasis" aria-current="page">
>> 个人中心
</a>
</li>
<li class="nav-item">
<a href="${webroot}/xx.jsp" class="nav-link link-body-emphasis" aria-current="page">
>> 已接任务
</a>
</li>
<li class="nav-item">
<a href="${webroot}/xx.jsp" class="nav-link link-body-emphasis" aria-current="page">
>> 历史任务
</a>
</li>
</c:when>
<c:otherwise>
<li class="nav-item">
<a href="${webroot}/" class="nav-link link-body-emphasis" aria-current="page">
>> 主页
</a>
</li>
</c:otherwise>
</c:choose>
</ul>
</div> </div>
</header> </header>
<main> <main>
@ -79,7 +47,6 @@
<div class="row"> <div class="row">
<div class="col-md-8 offset-md-2"> <div class="col-md-8 offset-md-2">
<!-- 工人个人中心主页内容 --> <!-- 工人个人中心主页内容 -->
<h1 class="text-center">工人个人中心</h1>
<div class="highlight"> <!-- 添加了红色边框的容器 --> <div class="highlight"> <!-- 添加了红色边框的容器 -->
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
@ -104,5 +71,6 @@
</div> </div>
</div> </div>
</main> </main>
<%@ include file="../includes/footer.jsp" %>
</body> </body>
</html> </html>

View File

@ -0,0 +1,46 @@
<%--
Created by IntelliJ IDEA.
User: sobear
Date: 2024/5/12
Time: 21:41
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>订单列表</title>
</head>
<body>
<h1>订单列表</h1>
<table border="1">
<tr>
<th>订单ID</th>
<th>设备ID</th>
<th>联系人ID</th>
<th>联系电话</th>
<th>维修地址</th>
<th>故障描述</th>
<th>故障图片</th>
<th>订单状态</th>
<th>创建时间</th>
<th>完成时间</th>
</tr>
<!-- 使用forEach循环来遍历订单列表 -->
<c:forEach items="${orders}" var="order">
<tr>
<td>${order.orderId}</td>
<td>${order.deviceId}</td>
<td>${order.studentId}</td>
<td>${order.phone}</td>
<td>${order.address}</td>
<td>${order.contact}</td>
<td>${order.faultImg}</td>
<td>${order.orderStatus}</td>
<td>${order.createTime}</td>
<td>${order.finishTime}</td>
</tr>
</c:forEach>
</table>
</body>
</html>

View File

@ -0,0 +1,16 @@
<%--
Created by IntelliJ IDEA.
User: sobear
Date: 2024/5/12
Time: 21:41
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<p>这是历史维修记录</p>
</body>
</html>

View File

@ -0,0 +1,16 @@
<%--
Created by IntelliJ IDEA.
User: sobear
Date: 2024/5/12
Time: 21:44
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<p>历史登录记录</p>
</body>
</html>

View File

@ -0,0 +1,16 @@
<%--
Created by IntelliJ IDEA.
User: sobear
Date: 2024/5/12
Time: 21:45
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<p>修改信息</p>
</body>
</html>