package com.mango.control.user;
import com.mango.pojo.BlackList;
import com.mango.pojo.Classroom;
import com.mango.pojo.Student;
import com.mango.service.Impl.BlackListServiceImpl;
import com.mango.service.Impl.ReservationServiceImpl;
import com.mango.service.Impl.StudentServiceImpl;
import com.mango.utils.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
public class MakeReservationController {
@Autowired
ReservationServiceImpl reservationService;
@Autowired
BlackListServiceImpl blackListService;
@Autowired
StudentServiceImpl studentService;
@RequestMapping("/make_reservation")
public String make_reservation(HttpServletRequest request, Model model) {
Map<String, Object> map = new HashMap<>();
String selectLocation = request.getParameter("selectLocation");
// System.out.println(selectLocation);
if (!"".equals(selectLocation) && selectLocation != null) {
map.put("selectLocation", selectLocation);
}
String selectBuildingName = request.getParameter("selectBuildingName");
// System.out.println(selectBuildingName);
if (!"".equals(selectBuildingName) && selectBuildingName != null) {
map.put("selectBuildingName", selectBuildingName);
}
String selectRoomName = request.getParameter("selectRoomName");
if (!"".equals(selectRoomName) && selectRoomName != null) {
map.put("selectRoomName", selectRoomName);
}
String selectRoomFloor = request.getParameter("selectRoomFloor");
if (!"".equals(selectRoomFloor) && selectRoomFloor != null) {
map.put("selectRoomFloor", selectRoomFloor);
}
String selectTime = request.getParameter("selectTime");
if (!"".equals(selectTime) && selectTime != null) {
String time_begin = selectTime.substring(0, selectTime.indexOf("-"));
// System.out.println(time_begin);
String time_end = selectTime.substring(selectTime.lastIndexOf("-") + 1);
// System.out.println(time_end);
map.put("time_begin", time_begin);
map.put("time_end", time_end);
// map.put("selectTime",selectTime);
}
String selectDate = request.getParameter("selectDate");
// System.out.println(selectDate);
if (!"".equals(selectDate) && selectDate != null) {
String date_begin = CommonUtil.getDateFormat(selectDate.substring(0, selectDate.indexOf(" ")));
// System.out.println(date_begin);
String date_end = CommonUtil.getDateFormat(selectDate.substring(selectDate.lastIndexOf(" ") + 1));
// System.out.println(date_end);
if (!date_begin.equals(date_end)) {
map.put("date_begin", date_begin);
map.put("date_end", date_end);
}
}
List<Classroom> allAvailableClassrooms = reservationService.getAllAvailableClassroom(map);
// System.out.println(allAvailableClassrooms.size());
String[] selectedCheckbox = request.getParameterValues("selectedCheckbox");
if (selectedCheckbox != null) {
Map<String, Map<String, String>> room_id_and_time_id = new HashMap<>();
for (String checkbox : selectedCheckbox) {
// System.out.println(checkbox);
String time_id = checkbox.substring(0, checkbox.indexOf("-"));
// System.out.println(time_id + "######");
String room_id = checkbox.substring(checkbox.indexOf("-") + 1);
// System.out.println(room_id + "######");
room_id_and_time_id.put(room_id.concat(time_id), new HashMap<>() {{
put(room_id, time_id);
}});
}
reservationService.setRoom_id_and_time_id(room_id_and_time_id);
return "redirect:confirm_reservation";
}
model.addAttribute("allAvailableClassrooms", allAvailableClassrooms);
return "make_reservation";
}
@RequestMapping("/confirm_reservation")
public String confirm_reservation(HttpServletRequest request, Model model) {
Map<String, Object> map = new HashMap<>();
map.put("room_id_and_time_id", reservationService.getRoom_id_and_time_id());
List<Classroom> allSelectClassrooms = reservationService.getAllAvailableClassroom(map);
reservationService.setAllSelectClassrooms(allSelectClassrooms);
model.addAttribute("allSelectClassrooms", allSelectClassrooms);
return "confirm_reservation";
}
@RequestMapping("/reservation_check")
public String reservation_check(HttpServletRequest request, Model model) {
Student loginUser = CommonUtil.getLoginUser(request);
System.out.println("开始预约...");
// 先查询是否在黑名单中
BlackList student = blackListService.getBlackedStudentById(loginUser.getS_id());
System.out.println(student);
if (student != null) {
model.addAttribute("msg","已被列入黑名单中,无法预约!");
return "confirm_reservation";
}else {
// 如果不在进行下一个判断
// 查询是否一星期存在三次取消预约,先通过sql找出所有取消预约的记录
if (studentService.isThreeTimesCanceledOfWeekById(loginUser.getS_id()) == true) {
model.addAttribute("msg","存在一个星期超过三次取消预约行为,无法预约!");
return "confirm_reservation";
}
}
reservationService.updateAddReservationInfo(loginUser.getS_id());
System.out.println("预约成功!");
return "redirect:make_reservation";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源说明】 基于Java开发的高校自习室预约管理系统源码+sql数据库.zip基于Java开发的高校自习室预约管理系统源码+sql数据库.zip基于Java开发的高校自习室预约管理系统源码+sql数据库.zip基于Java开发的高校自习室预约管理系统源码+sql数据库.zip基于Java开发的高校自习室预约管理系统源码+sql数据库.zip基于Java开发的高校自习室预约管理系统源码+sql数据库.zip基于Java开发的高校自习室预约管理系统源码+sql数据库.zip 基于Java开发的高校自习室预约管理系统源码+sql数据库.zip 基于Java开发的高校自习室预约管理系统源码+sql数据库.zip 基于Java开发的高校自习室预约管理系统源码+sql数据库.zip 【备注】 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载使用,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可直接用于毕设、课设、作业等。 欢迎下载,沟通交流,互相学习,共同进步!
资源推荐
资源详情
资源评论

























收起资源包目录





































































































共 336 条
- 1
- 2
- 3
- 4
资源评论


onnx
- 粉丝: 1w+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 亲子活动:幼儿园家长开放日方案.doc
- 潜江五七油焖大虾配方.doc
- 机械设备修理作业指导书-secret.docx
- 包头市某住宅楼景观工程设计合同.doc
- 工运学院空调工程施工组织设计方案.doc
- 消防安全操作规程.docx
- 通信维护无线网技术员竞职演讲.doc
- 商务中心9#、11#楼招标文件.doc
- 电解铝厂保持炉安装方案.doc
- 主要材料管理专项奖罚办法(讨论稿).docx
- 工程项目监理管理培训资料之进度控制管理.doc
- Unit2Developingideas课件高中英语外研版选修一.pptx
- 某工程质量通病防治方案.doc
- 第十二章-蛋白质的降解和氨基酸代谢.doc
- 龙湖商业地产简述浅谈商业地产干货.pdf
- 高层住宅楼造价指标分析.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
