基于javaweb+SpringBoot+JPA图书馆座位占座预约管理系统(管理员、老师、学生)
开发工具:eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
/**
* 修改密码页面
*
* @return
*/
@RequestMapping(value = "/update_pwd", method = RequestMethod.GET)
public String updatePwd() {
return "admin/system/update_pwd";
}
/**
* 修改密码表单提交
*
* @param oldPwd
* @param newPwd
* @return
*/
@RequestMapping(value = "/update_pwd", method = RequestMethod.POST)
@ResponseBody
public Result<Boolean> updatePwd(@RequestParam(name = "oldPwd", required = true) String oldPwd,
@RequestParam(name = "newPwd", required = true) String newPwd
) {
User loginedUser = SessionUtil.getLoginedUser();
if (!loginedUser.getPassword().equals(oldPwd)) {
return Result.success(true);
}
}
package com.demo.controller.admin;
import com.demo.common.bean.CodeMsg;
import com.demo.common.bean.PageBean;
import com.demo.common.bean.Result;
import com.demo.common.dto.SeatDTO;
import com.demo.common.util.DateUtil;
import com.demo.entity.*;
import com.demo.service.ReadRoomService;
import com.demo.service.SeatOrderService;
public static CodeMsg ADMIN_SEAT_EXIST=new CodeMsg(-15001,"座位已存在");
public static CodeMsg ADMIN_SEAT_NO_EXIST=new CodeMsg(-15009,"座位不存在");
public static CodeMsg ADMIN_SEAT_ADD_ERROR = new CodeMsg(-15002, "座位生成失败!");
public static CodeMsg ADMIN_SEAT_ORDER_ADD_EXIST = new CodeMsg(-15003, "选座失败,该座位已预约!");
public static CodeMsg ADMIN_SEAT_ORDER_STUDENT_EXIST = new CodeMsg(-15003, "选座失败,您已预约座位!");
public static CodeMsg ADMIN_SEAT_ORDER_DATE_ERROR = new CodeMsg(-15004, "选座失败,请选则正确的时间!");
public static CodeMsg ADMIN_SEAT_ORDER_DELETE_ERROR = new CodeMsg(-15005, "删除失败,登录用户不是学生!");
public static CodeMsg ADMIN_SEAT_ORDER_ILLEGALITY_DELETE = new CodeMsg(-15006, "删除失败!");
public static CodeMsg ADMIN_SEAT_STUDENT_ERROR = new CodeMsg(-15007, "请选使用学生账号登录!");
public static CodeMsg ADMIN_SEAT_STUDENT_INTEGRAL_ERROR = new CodeMsg(-15008, "您的积分不足!");
//后台班级管理类错误码
public static CodeMsg ADMIN_ClAZZ_EMPTY = new CodeMsg(-9000, "教师填写错误,请重新填写!");
public static final CodeMsg ADMIN_ClAZZNAME_EXIST =new CodeMsg (-9001, "该班级名已经存在,请换一个试试!");
public static CodeMsg ADMIN_ClAZZ_ADD_ERROR = new CodeMsg(-9002, "班级添加失败,请联系管理员!");
public static final CodeMsg ADMIN_CLAZZ_NOEXIST =new CodeMsg(-9003, "班级不存在!") ;
public static final CodeMsg ADMIN_CLAZZNAME_EXIST =new CodeMsg(-9004, "该班级名已存在,请联系管理员!") ;
public static final CodeMsg ADMIN_CLAZZ_TEACHER_EMPTY =new CodeMsg(-9005, "教师信息错误,请重新编辑!") ;
//学生扣分日志管理
public static final CodeMsg ADMIN_LOFINTEGRAL_CREDITS =new CodeMsg(-9005, "该学生没有那么多分数!") ;
}
package com.demo.common.util;
private int vcodeLen = 4;
/**
* 验证码图片字体大小
* 默认17
*/
private int fontsize = 21;
/**
* 验证码图片宽度
*/
private int width = (fontsize+1)*vcodeLen+10;
/**
* 验证码图片高度
*/
private int height = fontsize+12;
/**
/**
* @return 验证码字符个数
*/
public int getVcodeLen() {
return vcodeLen;
}
/**
* 设置验证码字符个数
* @param vcodeLen
*/
public void setVcodeLen(int vcodeLen) {
this.width = (fontsize+3)*vcodeLen+10;
this.vcodeLen = vcodeLen;
}
/**
* @return 字体大小
*/
public int getFontsize() {
return fontsize;
}
/**
* 设置字体大小
* @param fontsize
*/
public class UserController {
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
private OperaterLogService operaterLogService;
/**
* 用户列表页面
* @param model
* @param user
* @param pageBean
* @return
*/
@RequestMapping(value="/list")
public String list(Model model,User user,PageBean<User> pageBean){
model.addAttribute("title", "用户列表");
model.addAttribute("nickName", user.getNickName());
model.addAttribute("pageBean", userService.findList(user, pageBean));
return "admin/user/list";
}
/**
* 新增用户页面
* @param model
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Result<Boolean> add(@RequestParam(name = "id", required = true) Long id) {
ReadingRoom readingRoom = readRoomService.findById(id);
if (seatService.isExistReadingRoomId(id)) {
return Result.error(CodeMsg.ADMIN_SEAT_EXIST);
}
List<Seat> seats = new ArrayList<>();
for (int x = 1; x <= readingRoom.getLie(); x++) {
for (int y = 1; y <= readingRoom.getRow(); y++) {
Seat seat = new Seat();
seat.setReadingRoom(readingRoom);
seat.setxAxis(x);
CodeMsg validate = ValidateEntityUtil.validate(clazz);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
if(clazz.getTeacher() == null || clazz.getTeacher().getTeacherSno() == null){
return Result.error(CodeMsg.ADMIN_ClAZZ_EMPTY );
}
//判断班级名是否存在
if(clazzService.isExistClaName(clazz.getClaname(), 0l)){
return Result.error(CodeMsg.ADMIN_ClAZZNAME_EXIST);
}
//到这说明一切符合条件,进行数据库新增
if(clazzService.save(clazz) == null){
return Result.error(CodeMsg.ADMIN_ClAZZ_ADD_ERROR);
}
operaterLogService.add("添加班级,班级名:" + clazz.getClaname());
return Result.success(true);
}
BufferedImage rotateVcodeImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = rotateVcodeImage.createGraphics();
//填充背景色
g2d.setColor(new Color(246, 240, 250));
g2d.fillRect(0, 0, width, height);
if(drawline){
drawDisturbLine(g2d);
}
//在图片上画验证码
for(int i = 0;i < vcode.length();i++){
BufferedImage rotateImage = getRotateImage(vcode.charAt(i));
g2d.drawImage(rotateImage, null, (int) (this.height * 0.7) * i, 0);
}
g2d.dispose();
return rotateVcodeImage;
}
/**
* 生成验证码
* @return 验证码
*/
public String generatorVCode(){
import com.demo.entity.SeatOrder;
import com.demo.entity.TimeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.*;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class SeatService {
@Autowired
private SeatDao seatDao;
@Autowired
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
技术框架
JSP JavaScript SpringBoot SpringDataJPA FreeMarker MySQL
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
管理员:学生管理、教师管理、阅览室类型管理、阅览室管理(座位生成等)、学生信用积分管理、座位预约统计管理等。
学生:登录、修改个人信息、阅览室查看、选座信息查看、选座、取消选座等。
教师:登录、阅览室管理、学生信用管理:可根据学生表现进行扣分、奖励等,扣分达到设定的值则无法进行选座。