chore: verify data

This commit is contained in:
xtaodada 2024-06-06 20:13:01 +08:00
parent 2c2c107dad
commit 776ddd2801
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
8 changed files with 41 additions and 9 deletions

View File

@ -21,7 +21,7 @@ public class StuConsultController {
this.orderDao = orderDao; this.orderDao = orderDao;
} }
@RequestMapping("/stu/consult") @RequestMapping("/stu/consult.do")
public String consult(HttpServletRequest request, @SessionAttribute Stu stu) { public String consult(HttpServletRequest request, @SessionAttribute Stu stu) {
ArrayList<Order> orders = orderDao.findByStudent_id(stu.getUserid()); ArrayList<Order> orders = orderDao.findByStudent_id(stu.getUserid());
if (orders != null) { if (orders != null) {

View File

@ -22,7 +22,7 @@ public class StuCurrentController {
this.orderDao = orderDao; this.orderDao = orderDao;
} }
@GetMapping("/stu/current") @GetMapping("/stu/current.do")
public String current(HttpServletRequest request, @SessionAttribute Stu stu) { public String current(HttpServletRequest request, @SessionAttribute Stu stu) {
ArrayList<Order> orders = orderDao.findCurrent(stu.getUserid()); ArrayList<Order> orders = orderDao.findCurrent(stu.getUserid());
if (orders != null) { if (orders != null) {

View File

@ -43,7 +43,13 @@ public class StuDataController {
return "/stu/data"; return "/stu/data";
} }
if ("male".equals(gender) || "female".equals(gender)) {
stu.setGender(gender); stu.setGender(gender);
} else {
req.setAttribute("stuEditMess", "性别格式不正确");
return "/stu/data";
}
int update = stuDao.update(stu); int update = stuDao.update(stu);
if (update > 0) { if (update > 0) {
req.setAttribute("stuEditMess", "修改成功"); req.setAttribute("stuEditMess", "修改成功");

View File

@ -3,10 +3,7 @@ package cn.edu.cqwu.repair.controller.stu;
import cn.edu.cqwu.repair.dao.DeviceDao; import cn.edu.cqwu.repair.dao.DeviceDao;
import cn.edu.cqwu.repair.dao.OrderDao; import cn.edu.cqwu.repair.dao.OrderDao;
import cn.edu.cqwu.repair.dao.StuDao; import cn.edu.cqwu.repair.dao.StuDao;
import cn.edu.cqwu.repair.entity.Device; import cn.edu.cqwu.repair.entity.*;
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -56,6 +53,11 @@ public class StuUploadController {
String phone, String phone,
MultipartFile[] myfile, MultipartFile[] myfile,
HttpServletRequest req) { 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 order = new Order();
order.setDeviceId(deviceId); order.setDeviceId(deviceId);
order.setStudentId(stu.getUserid()); order.setStudentId(stu.getUserid());

View File

@ -13,4 +13,6 @@ public interface DeviceDao {
ArrayList<Device> findAllDevice(int deviceTypeId, int deviceAddressId, int deviceStatus); ArrayList<Device> findAllDevice(int deviceTypeId, int deviceAddressId, int deviceStatus);
Device findDevice(int deviceId);
} }

View File

@ -37,4 +37,11 @@ public class DeviceDaoImpl implements DeviceDao {
} }
return (ArrayList<Device>) mapper.selectListByQuery(qw); return (ArrayList<Device>) mapper.selectListByQuery(qw);
} }
@Override
public Device findDevice(int deviceId) {
QueryWrapper qw = new QueryWrapper();
qw.where(DEVICE.DEVICE_ID.eq(deviceId));
return mapper.selectOneByQuery(qw);
}
} }

View File

@ -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;
}
}

View File

@ -30,12 +30,12 @@
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a href="${webroot}/stu/current" class="nav-link link-body-emphasis" aria-current="page"> <a href="${webroot}/stu/current.do" class="nav-link link-body-emphasis" aria-current="page">
>> 未完成维修单 >> 未完成维修单
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a href="${webroot}/stu/consult" class="nav-link link-body-emphasis" aria-current="page"> <a href="${webroot}/stu/consult.do" class="nav-link link-body-emphasis" aria-current="page">
>> 历史维修单 >> 历史维修单
</a> </a>
</li> </li>