Compare commits

...

3 Commits

Author SHA1 Message Date
wobeitaoleshigexuruo
395d43c7a3 Merge remote-tracking branch 'origin/master' 2024-06-05 21:42:24 +08:00
wobeitaoleshigexuruo
79f5908ab2 stu upload 2024-06-05 21:42:11 +08:00
wobeitaoleshigexuruo
8eae23474d stu upload 2024-06-05 21:35:27 +08:00
13 changed files with 385 additions and 38 deletions

View File

@ -1,6 +1,7 @@
package cn.edu.cqwu.repair.controller.stu;
import cn.edu.cqwu.repair.dao.OrderDao;
import cn.edu.cqwu.repair.entity.Order;
import cn.edu.cqwu.repair.entity.Stu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -8,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttribute;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
@Controller
public class StuConsultController {
@ -21,8 +23,14 @@ public class StuConsultController {
@RequestMapping("/stu/consult")
public String consult(HttpServletRequest request, @SessionAttribute Stu stu) {
request.setAttribute("repairOrder", orderDao.findByStudent_id(stu.getUserid()));
ArrayList<Order> orders = orderDao.findByStudent_id(stu.getUserid());
if(orders!=null) {
System.out.println(orders);
request.setAttribute("Orders", orders);
}else{
System.out.println("订单空");
request.setAttribute("stuConsultMess","订单为空");
}
return "/stu/consult";
}

View File

@ -0,0 +1,50 @@
package cn.edu.cqwu.repair.controller.stu;
import cn.edu.cqwu.repair.dao.OrderDao;
import cn.edu.cqwu.repair.entity.Order;
import cn.edu.cqwu.repair.entity.OrderStatus;
import cn.edu.cqwu.repair.entity.Stu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
@Controller
public class StuCurrentController {
OrderDao orderDao;
@Autowired
public StuCurrentController(OrderDao orderDao) {
this.orderDao = orderDao;
}
@GetMapping("/stu/current")
public String current(HttpServletRequest request, @SessionAttribute Stu stu) {
ArrayList<Order> orders = orderDao.findByStudent_id(stu.getUserid());
ArrayList<Order> orders1 = new ArrayList<>();
for (Order order : orders) {
if(order.getOrderStatus()== OrderStatus.UNASSIGNED.value|| order.getOrderStatus()==OrderStatus.PROGRESS.value){
orders1.add(order);
}
}
if(orders1!=null) {
System.out.println(orders1);
request.setAttribute("Orders", orders1);
}else{
System.out.println("订单空");
request.setAttribute("stuCurrentMess","订单为空");
}
return "/stu/current";
}
}

View File

@ -0,0 +1,55 @@
package cn.edu.cqwu.repair.controller.stu;
import cn.edu.cqwu.repair.dao.StuDao;
import cn.edu.cqwu.repair.entity.Stu;
import cn.edu.cqwu.repair.entity.mapper.StuMapper;
import com.mybatisflex.core.activerecord.Model;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
@Controller
public class StuDataController {
StuDao stuDao;
@Autowired
public StuDataController(StuDao stuDao) {
this.stuDao = stuDao;
}
// @RequestMapping(value = "/stu/data")
// public String stuData( ) {
// return "stu/data";
// }
@PostMapping("stu/data")
public String stuData(@Param("username")String username, @Param("gender")String gender, HttpServletRequest req){
Stu stu = new Stu();
Stu stu1 = (Stu)req.getSession().getAttribute("stu");
stu.setUsername(username);
stu.setGender(gender);
stu.setPassword(stu1.getPassword());
stu.setUserid(stu1.getUserid());
stu.setRegip(stu1.getRegip());
stu.setStatus(stu1.getStatus());
stu.setRegtime(stu1.getRegtime());
stu.setUpdateTime(stu1.getUpdateTime());
stu.setUserNo(stu1.getUserNo());
int update = stuDao.update(stu);
if(update>0){
req.setAttribute("stuMess", "修改成功");
}else{
req.setAttribute("stuMess", "修改失败");
}
return "stu/data";
}
}

View File

@ -29,7 +29,7 @@ DeviceDao deviceDao;
this.deviceDao = deviceDao;
}
// @RequestMapping("/stu/upload.jsp")
// @RequestMapping("/stu/upload")
// public String consult(HttpServletRequest request) {
// request.setAttribute("devices", deviceDao.findAllDevice());
//

View File

@ -7,7 +7,7 @@ import java.util.ArrayList;
public interface OrderDao {
int add(Order order);
Order findByStudent_id(int id);
ArrayList<Order> findByStudent_id(int stuId);
ArrayList<Order> findByWorkerId(int workerId);
public int statusModify(int orderId);

View File

@ -6,7 +6,7 @@ import java.util.ArrayList;
public interface StuDao {
public int add(Stu stu);
public int update(Stu stu);
public Stu findByUsername(String username);
public Stu validateLogin(String username, String password);

View File

@ -28,8 +28,10 @@ public class OrderDaoImpl implements OrderDao {
}
@Override
public Order findByStudent_id(int id) {
return null;
public ArrayList<Order> findByStudent_id(int stuId) {
QueryWrapper qw = new QueryWrapper();
qw.select(ORDER.ALL_COLUMNS).where(ORDER.STUDENT_ID.eq(stuId));
return (ArrayList<Order>) mapper.selectListByQuery(qw);
}
@Override

View File

@ -22,6 +22,9 @@ public class StuDaoImpl implements StuDao {
public int add(Stu stu) {
return MAPPER.insert(stu);
}
public int update(Stu stu) {
return MAPPER.update(stu);
}
@Override
public Stu findByUsername(String username) {

View File

@ -0,0 +1,14 @@
package cn.edu.cqwu.repair.entity;
public enum OrderStatus {
UNASSIGNED(0),
PROGRESS(1),
FINISHED(2);
public int value;
OrderStatus(int value) {
this.value = value;
}
}

View File

@ -15,10 +15,30 @@
<c:choose>
<c:when test="${not empty sessionScope.stu}">
<li class="nav-item">
<a href="${webroot}/stu/notice.jsp" class="nav-link link-body-emphasis" aria-current="page">
<a href="${webroot}/stu/main.jsp" class="nav-link link-body-emphasis" aria-current="page">
>> 主页
</a>
</li>
<li class="nav-item">
<a href="${webroot}/stu/data.jsp" class="nav-link link-body-emphasis" aria-current="page">
>> 个人资料
</a>
</li>
<li class="nav-item">
<a href="${webroot}/stu/upload.jsp" class="nav-link link-body-emphasis" aria-current="page">
>> 上传订单
</a>
</li>
<li class="nav-item">
<a href="${webroot}/stu/current" class="nav-link link-body-emphasis" aria-current="page">
>> 当前订单
</a>
</li>
<li class="nav-item">
<a href="${webroot}/stu/consult" class="nav-link link-body-emphasis" aria-current="page">
>> 历史订单
</a>
</li>
</c:when>
<c:when test="${not empty sessionScope.adminUser}">
<li class="nav-item">

View File

@ -6,7 +6,7 @@
<%@ page isELIgnored="false" %>
<c:set var="title" value="上传表单"/>
<c:set var="webroot" value="${pageContext.request.contextPath}"/>
<c:set var="repairOrder" value="${requestScope.repairOrder}"/>
<c:set var="repairOrder" value="${requestScope.Orders}"/>
<html>
<head>
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css">
@ -23,43 +23,70 @@
<main class="d-flex flex-nowrap">
<%@ include file="../includes/header.jsp" %>
<main class="form-signin w-100 m-auto">
<c:if test="${not empty repairOrder}">
<div>
<p><strong>联系人名称:</strong>${repairOrder.contact}</p>
<p><strong>联系人电话:</strong>${repairOrder.phone}</p>
<p><strong>详细地点:</strong>${repairOrder.address}</p>
<p><strong>故障描述:</strong>${repairOrder.faultDesc}</p>
<p><strong>故障图片:</strong><img src="${repairOrder.faultImg}" alt="故障图片"></p>
<p><strong>处理状态:</strong>
<c:choose>
<c:when test="${repairOrder.orderStatus==0}">
待安排维修人员
</c:when>
<c:when test="${repairOrder.orderStatus==1}">
正在维修中
</c:when>
<c:otherwise>
维修已完成
</c:otherwise>
</c:choose>
</p>
<main class=" w-100 m-auto">
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
<h1 class="h3 mb-3 fw-normal">查看订单</h1>
<c:if test="${not empty requestScope.stuConsultMess}">
<div class="alert alert-warning" role="alert">
${requestScope.stuConsultMess}
</div>
</c:if>
<div class="form-floating">
<c:if test="${not empty requestScope.Orders}">
<table class="table">
<thead>
<tr>
<th scope="col">序号</th>
<th scope="col">联系人名称</th>
<th scope="col">联系人电话</th>
<th scope="col">详细地点</th>
<th scope="col">故障描述</th>
<th scope="col">故障图片</th>
<th scope="col">处理状态</th>
</tr>
</thead>
<tbody>
<c:forEach var="repairOrder" items="${requestScope.Orders}" varStatus="loop">
<tr>
<td>${loop.index + 1}</td>
<td>${repairOrder.contact}</td>
<td>${repairOrder.phone}</td>
<td>${repairOrder.address}</td>
<td>${repairOrder.faultDesc}</td>
<td><img src="${repairOrder.faultImg}" alt="故障图片"></td>
<td>
<c:choose>
<c:when test="${repairOrder.orderStatus==0}">
待安排维修人员
</c:when>
<c:when test="${repairOrder.orderStatus==1}">
正在维修中
</c:when>
<c:otherwise>
维修已完成
</c:otherwise>
</c:choose>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</c:if>
</div>
</main>
</main>
<script src="${webroot}/js/pass.js" type="javascript"></script>
<script>
const toastLiveExample = document.getElementById('liveToast')
<%--<script src="${webroot}/js/pass.js" type="javascript"></script>--%>
<%--<script>--%>
<%-- const toastLiveExample = document.getElementById('liveToast')--%>
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample)
toastBootstrap.show()
</script>
<%-- const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample)--%>
<%-- toastBootstrap.show()--%>
<%--</script>--%>
<%--<script src="${webroot}/js/pass.js"></script>--%>
</body>

View File

@ -0,0 +1,99 @@
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2024/5/16
Time: 10:22
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>
<c:set var="title" value="上传表单"/>
<c:set var="webroot" value="${pageContext.request.contextPath}"/>
<c:set var="repairOrder" value="${requestScope.Orders}"/>
<html>
<head>
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>${title}</title>
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css" crossorigin="anonymous">
<script src="${webroot}/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="${webroot}/styles/sidebar.css" crossorigin="anonymous">
<link rel="stylesheet" href="${webroot}/styles/index.css" crossorigin="anonymous">
</head>
<body>
<main class="d-flex flex-nowrap">
<%@ include file="../includes/header.jsp" %>
<main class=" w-100 m-auto">
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
<h1 class="h3 mb-3 fw-normal">查看订单</h1>
<c:if test="${not empty requestScope.stuCurrentMess}">
<div class="alert alert-warning" role="alert">
${requestScope.stuCurrentMess}
</div>
</c:if>
<div class="form-floating">
<c:if test="${not empty requestScope.Orders}">
<table class="table">
<thead>
<tr>
<th scope="col">序号</th>
<th scope="col">联系人名称</th>
<th scope="col">联系人电话</th>
<th scope="col">详细地点</th>
<th scope="col">故障描述</th>
<th scope="col">故障图片</th>
<th scope="col">处理状态</th>
</tr>
</thead>
<tbody>
<c:forEach var="repairOrder" items="${requestScope.Orders}" varStatus="loop">
<tr>
<td>第 ${loop.index + 1} 项订单</td>
<td><strong>联系人名称:</strong>${repairOrder.contact}</td>
<td><strong>联系人名称:</strong>${repairOrder.contact}</td>
<td><strong>联系人电话:</strong>${repairOrder.phone}</td>
<td><strong>详细地点:</strong>${repairOrder.address}</td>
<td><strong>故障描述:</strong>${repairOrder.faultDesc}</td>
<td><strong>故障图片:</strong><img src="${repairOrder.faultImg}" alt="故障图片"></td>
<td><strong>处理状态:</strong>
<c:choose>
<c:when test="${repairOrder.orderStatus==0}">
待安排维修人员
</c:when>
<c:when test="${repairOrder.orderStatus==1}">
正在维修中
</c:when>
<c:otherwise>
维修已完成
</c:otherwise>
</c:choose>
</td>
</tr>
</c:forEach>
</c:if>
</tbody>
</table>
</div>
</main>
</main>
</body>
</html>

View File

@ -0,0 +1,69 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>
<c:set var="title" value="个人资料"/>
<c:set var="webroot" value="${pageContext.request.contextPath}"/><html>
<c:set var="stu" value="${sessionScope.stu}"/>
<head>
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>${title}</title>
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css" crossorigin="anonymous">
<script src="${webroot}/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="${webroot}/styles/sidebar.css" crossorigin="anonymous">
<link rel="stylesheet" href="${webroot}/styles/index.css" crossorigin="anonymous">
</head>
<body>
<main class="d-flex flex-nowrap">
<%@ include file="../includes/header.jsp" %>
<main class="form-signin w-100 m-auto">
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
<h1 class="h3 mb-3 fw-normal">个人资料</h1>
<c:if test="${not empty requestScope.stuMess}">
<div class="alert alert-warning" role="alert">
${requestScope.stuMess}
</div>
</c:if>
<div class="form-floating">
<form action="stu/data" method="post">
<div class="form-floating">
<label for="username">Username:</label><br>
<input type="text" id="username" name="username" value="${stu.username}"><br><br>
</div>
<label for="gender">Gender:</label><br>
<div class="form-floating">
<select id="gender" name="gender" >
<c:choose>
<c:when test="${stu.gender == 'male'}">
<option value="male" selected>Male</option>
<option value="female">Female</option>
</c:when>
<c:otherwise>
<option value="male">Male</option>
<option value="female" selected>Female</option>
</c:otherwise>
</c:choose>
</select><br><br>
</div>
<button class="btn btn-primary w-100 py-2" type="submit" id="submit">提交</button>
</form>
</div>
</main>
</main>
</body>
</html>