From 776ddd280195b32af899d508b878e5e8e8ca1055 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Thu, 6 Jun 2024 20:13:01 +0800 Subject: [PATCH] chore: verify data --- .../controller/stu/StuConsultController.java | 2 +- .../controller/stu/StuCurrentController.java | 2 +- .../repair/controller/stu/StuDataController.java | 8 +++++++- .../controller/stu/StuUploadController.java | 10 ++++++---- .../java/cn/edu/cqwu/repair/dao/DeviceDao.java | 2 ++ .../edu/cqwu/repair/dao/impl/DeviceDaoImpl.java | 7 +++++++ .../cn/edu/cqwu/repair/entity/DeviceStatus.java | 15 +++++++++++++++ src/main/webapp/includes/menu.jsp | 4 ++-- 8 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 src/main/java/cn/edu/cqwu/repair/entity/DeviceStatus.java diff --git a/src/main/java/cn/edu/cqwu/repair/controller/stu/StuConsultController.java b/src/main/java/cn/edu/cqwu/repair/controller/stu/StuConsultController.java index 10f70ae..ef1c9ad 100644 --- a/src/main/java/cn/edu/cqwu/repair/controller/stu/StuConsultController.java +++ b/src/main/java/cn/edu/cqwu/repair/controller/stu/StuConsultController.java @@ -21,7 +21,7 @@ public class StuConsultController { this.orderDao = orderDao; } - @RequestMapping("/stu/consult") + @RequestMapping("/stu/consult.do") public String consult(HttpServletRequest request, @SessionAttribute Stu stu) { ArrayList orders = orderDao.findByStudent_id(stu.getUserid()); if (orders != null) { diff --git a/src/main/java/cn/edu/cqwu/repair/controller/stu/StuCurrentController.java b/src/main/java/cn/edu/cqwu/repair/controller/stu/StuCurrentController.java index 7ff76ea..2bca1a4 100644 --- a/src/main/java/cn/edu/cqwu/repair/controller/stu/StuCurrentController.java +++ b/src/main/java/cn/edu/cqwu/repair/controller/stu/StuCurrentController.java @@ -22,7 +22,7 @@ public class StuCurrentController { this.orderDao = orderDao; } - @GetMapping("/stu/current") + @GetMapping("/stu/current.do") public String current(HttpServletRequest request, @SessionAttribute Stu stu) { ArrayList orders = orderDao.findCurrent(stu.getUserid()); if (orders != null) { diff --git a/src/main/java/cn/edu/cqwu/repair/controller/stu/StuDataController.java b/src/main/java/cn/edu/cqwu/repair/controller/stu/StuDataController.java index f017922..48c9a90 100644 --- a/src/main/java/cn/edu/cqwu/repair/controller/stu/StuDataController.java +++ b/src/main/java/cn/edu/cqwu/repair/controller/stu/StuDataController.java @@ -43,7 +43,13 @@ public class StuDataController { return "/stu/data"; } - stu.setGender(gender); + if ("male".equals(gender) || "female".equals(gender)) { + stu.setGender(gender); + } else { + req.setAttribute("stuEditMess", "性别格式不正确"); + return "/stu/data"; + } + int update = stuDao.update(stu); if (update > 0) { req.setAttribute("stuEditMess", "修改成功"); diff --git a/src/main/java/cn/edu/cqwu/repair/controller/stu/StuUploadController.java b/src/main/java/cn/edu/cqwu/repair/controller/stu/StuUploadController.java index ebd00e2..83040e2 100644 --- a/src/main/java/cn/edu/cqwu/repair/controller/stu/StuUploadController.java +++ b/src/main/java/cn/edu/cqwu/repair/controller/stu/StuUploadController.java @@ -3,10 +3,7 @@ package cn.edu.cqwu.repair.controller.stu; import cn.edu.cqwu.repair.dao.DeviceDao; import cn.edu.cqwu.repair.dao.OrderDao; import cn.edu.cqwu.repair.dao.StuDao; -import cn.edu.cqwu.repair.entity.Device; -import cn.edu.cqwu.repair.entity.Order; -import cn.edu.cqwu.repair.entity.OrderStatus; -import cn.edu.cqwu.repair.entity.Stu; +import cn.edu.cqwu.repair.entity.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -56,6 +53,11 @@ public class StuUploadController { String phone, MultipartFile[] myfile, HttpServletRequest req) { + Device device = deviceDao.findDevice(deviceId); + if (device == null || device.getDeviceStatus() != DeviceStatus.OK.value) { + req.setAttribute("stuUploadMess", "设备不存在或设备已被其他人报修"); + return "/stu/upload"; + } Order order = new Order(); order.setDeviceId(deviceId); order.setStudentId(stu.getUserid()); diff --git a/src/main/java/cn/edu/cqwu/repair/dao/DeviceDao.java b/src/main/java/cn/edu/cqwu/repair/dao/DeviceDao.java index f7cb4f1..9138896 100644 --- a/src/main/java/cn/edu/cqwu/repair/dao/DeviceDao.java +++ b/src/main/java/cn/edu/cqwu/repair/dao/DeviceDao.java @@ -13,4 +13,6 @@ public interface DeviceDao { ArrayList findAllDevice(int deviceTypeId, int deviceAddressId, int deviceStatus); + Device findDevice(int deviceId); + } diff --git a/src/main/java/cn/edu/cqwu/repair/dao/impl/DeviceDaoImpl.java b/src/main/java/cn/edu/cqwu/repair/dao/impl/DeviceDaoImpl.java index 7056a28..1afd973 100644 --- a/src/main/java/cn/edu/cqwu/repair/dao/impl/DeviceDaoImpl.java +++ b/src/main/java/cn/edu/cqwu/repair/dao/impl/DeviceDaoImpl.java @@ -37,4 +37,11 @@ public class DeviceDaoImpl implements DeviceDao { } return (ArrayList) mapper.selectListByQuery(qw); } + + @Override + public Device findDevice(int deviceId) { + QueryWrapper qw = new QueryWrapper(); + qw.where(DEVICE.DEVICE_ID.eq(deviceId)); + return mapper.selectOneByQuery(qw); + } } diff --git a/src/main/java/cn/edu/cqwu/repair/entity/DeviceStatus.java b/src/main/java/cn/edu/cqwu/repair/entity/DeviceStatus.java new file mode 100644 index 0000000..c1f4c67 --- /dev/null +++ b/src/main/java/cn/edu/cqwu/repair/entity/DeviceStatus.java @@ -0,0 +1,15 @@ +package cn.edu.cqwu.repair.entity; + +/** + * @author xtao + */ +public enum DeviceStatus { + OK(0), + REPAIR(1); + + public final int value; + + DeviceStatus(int value) { + this.value = value; + } +} diff --git a/src/main/webapp/includes/menu.jsp b/src/main/webapp/includes/menu.jsp index 49ea192..7f1fd95 100644 --- a/src/main/webapp/includes/menu.jsp +++ b/src/main/webapp/includes/menu.jsp @@ -30,12 +30,12 @@