Java项目:125SpringBoot教室预约管理系统

发布时间:2024年01月23日

博主主页:Java旅途
简介:分享计算机知识、学习路线、系统源码及教程
文末获取源码

一、项目介绍

教室预约管理系统使用SpringBoot+Mybatis进行开发,系统整体分为前台和后台,后台主要对教室,用户等信息进行管理,前台总共分为学生、教室、辅导员、楼长四种角色,通过预约教室,多层审批完成教室预约功能。系统详细功能如下

后台功能:

  • 用户管理
  • 教学楼管理
  • 教室管理
  • 审批查询
  • 班级管理

前台功能:

  • 学生

    • 教室预约
    • 个人中心
    • 留言
  • 教师

    • 教师预约
    • 个人中心
    • 留言
  • 辅导员

    • 审批
    • 个人中心
  • 楼长

    • 审批
    • 个人中心
    • 留言板

二、技术框架

  • 后端:SpringBoot,Mybatis
  • 前端:jquery

三、安装教程

  1. 用idea打开项目
  2. 在idea中配置jdk环境
  3. 配置maven环境并下载依赖
  4. 新建数据库,导入数据库文件
  5. 在application.yml文件中将数据库账号密码改成自己本地的
  6. 启动运行,进行访问。
后台管理员账号密码: admin/123456
前台学生账号密码:xx/123456
前台教师账号密码:lyc/123456
前台辅导员账号密码:zs/123456
前台楼长账号密码:wm/123456

四、项目截图

image-20230721151012695

image-20230721151025659

image-20230721151043270

image-20230721151127832

image-20230721151150815

image-20230721151216050

五、相关代码

RoomController

package edu.room.manage.controller.console;

import com.github.pagehelper.PageInfo;
import edu.room.manage.common.annotation.Operation;
import edu.room.manage.common.controller.BaseController;
import edu.room.manage.common.exception.MessageException;
import edu.room.manage.common.mybatis.condition.MybatisCondition;
import edu.room.manage.common.utils.ReturnUtils;
import edu.room.manage.domain.Room;
import edu.room.manage.dto.RoomDTO;
import edu.room.manage.service.FloorService;
import edu.room.manage.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.validation.Valid;

/**
 */
@Controller
@RequestMapping("/console/room")
public class RoomController extends BaseController {

    @Autowired
    private RoomService  roomService;
    @Autowired
    private FloorService floorService;

    @Operation("查看教学楼")
    @RequestMapping(value = "/index", method = {RequestMethod.GET})
    public String index(Model model) {
        return "console/room/index";
    }

    @Operation("教学楼详情")
    @RequestMapping(value = "detail/{id}", method = {RequestMethod.GET})
    public String from(@PathVariable Integer id, Model model) {
        Room room;
        if (id != 0) {
            room = roomService.selectByPrimaryKey(id);
        } else {
            room = new Room();
        }
        model.addAttribute("room", room);
        model.addAttribute("floorList", floorService.selectAll());
        return "console/room/detail";
    }

    @Operation("添加更新教学楼")
    @RequestMapping(value = "/merge", method = {RequestMethod.POST})
    public String save(@Valid Room room, BindingResult result, RedirectAttributes attributes) {
        if (result.hasErrors()) {
            throw new MessageException(result.getAllErrors().get(0).getDefaultMessage());
        }
        roomService.merge(room);
        return redirect("/console/room/index", "操作成功", attributes);
    }

    @Operation("删除教学楼")
    @RequestMapping(value = "/delete", method = {RequestMethod.GET})
    @ResponseBody
    public ModelMap delete(Integer id) {
        roomService.deleteByPrimaryKey(id);
        return ReturnUtils.success("操作成功", null, null);
    }

    @ResponseBody
    @RequestMapping(value = "/list", method = {RequestMethod.GET})
    public ModelMap list(RoomDTO room) {
        ModelMap map = new ModelMap();
        MybatisCondition condition = new MybatisCondition()
                .like("r.name", room.getName())
                .like("f.name", room.getFloorName())
                .like("r.floor", room.getFloor())
                .page(room);
        PageInfo<RoomDTO> pageInfo = roomService.selectDtoPage(condition);
        map.put("pageInfo", pageInfo);
        return ReturnUtils.success("加载成功", map);
    }


}

HomeController

package edu.room.manage.controller.console;

import edu.room.manage.common.annotation.Operation;
import edu.room.manage.common.context.Constant;
import edu.room.manage.common.controller.BaseController;
import edu.room.manage.common.utils.Md5Utils;
import edu.room.manage.domain.Admin;
import edu.room.manage.domain.Floor;
import edu.room.manage.domain.Room;
import edu.room.manage.domain.User;
import edu.room.manage.service.AdminService;
import edu.room.manage.service.FloorService;
import edu.room.manage.service.RoomService;
import edu.room.manage.service.UserService;
import edu.room.manage.valid.ValidUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.validation.Valid;
import java.util.HashMap;
import java.util.Map;


/**
 */
@Controller
@RequestMapping("console")
@Slf4j
public class HomeController extends BaseController {


    @Autowired
    private UserService  userService;
    @Autowired
    private RoomService  roomService;
    @Autowired
    private FloorService floorService;
    @Autowired
    private AdminService adminService;


    /**
     * 首页
     *
     * @param model
     * @return
     */
    @RequestMapping(value = "index", method = {RequestMethod.GET})

    public String index(Model model) {
        return "console/index";
    }


    /**
     * 首页展示
     *
     * @param model
     * @return
     */
    @RequestMapping(value = "main", method = {RequestMethod.GET})
    public String right(Model model) {
        model.addAllAttributes(this.getTotal());
        return "console/right";
    }

    /**
     * 登录页
     *
     * @return
     */
    @RequestMapping(value = "login", method = RequestMethod.GET)
    public String loginForm() {
        return "console/login";
    }

    @Operation("登录")
    @RequestMapping(value = "login", method = RequestMethod.POST)
    public String loginPost(@Valid ValidUser validUser, BindingResult bindingResult, RedirectAttributes redirectAttributes) {
        if (bindingResult.hasErrors()) {
            redirectAttributes.addFlashAttribute(Constant.ERROR_MESSAGE, bindingResult.getAllErrors().get(0).getDefaultMessage());
            return "redirect:login";
        }
        String username = validUser.getUsername();
        Admin  admin    = (Admin) userService.login(validUser.getUsername(), validUser.getPassword(), User.UserRoleEnum.ADMIN);
        if (null == admin) {
            redirectAttributes.addFlashAttribute(Constant.ERROR_MESSAGE, "用户名或密码不正确");
            return "redirect:login";
        } else {
            logger.info("用户[" + username + "]登录认证通过");
            session.setAttribute(Constant.SESSION_ADMIN, admin);
            return "redirect:index";
        }
    }

    /**
     * 退出登录
     *
     * @param redirectAttributes
     * @return
     */
    @RequestMapping(value = "/logout", method = RequestMethod.GET)
    public String logout(RedirectAttributes redirectAttributes) {
        log.info("【退出登录】 {}", loginAdmin().getUsername());
        session.removeAttribute(SESSION_ADMIN);
        redirectAttributes.addFlashAttribute(Constant.ERROR_MESSAGE, "您已安全退出");
        return "redirect:login";
    }

    /**
     * 修改密码
     *
     * @return
     */
    @RequestMapping(value = "/modifyPwd", method = {RequestMethod.GET})
    public String modifyPwd() {
        return "console/modify-pwd";
    }

    @Operation("修改用户密码")
    @RequestMapping(value = "/modifyPwd", method = {RequestMethod.POST})
    public String modifyPwd(String pwd, String password, String password2, RedirectAttributes attributes) {
        if (!password.equals(password2)) {
            return redirect("/console/modifyPwd", "两次密码不一样", attributes);
        }
        Admin user = adminService.selectByPrimaryKey(loginAdmin().getId());
        if (null != user) {
            if (!Md5Utils.encode(pwd).equalsIgnoreCase(user.getPassword())) {
                return redirect("/console/modifyPwd", "原密码错误", attributes);
            }
            String newPassword = Md5Utils.encode(password);
            user.setPassword(newPassword);
            adminService.updateByPrimaryKeySelective(user);
            return redirect("/console/modifyPwd", "修改成功", attributes);
        } else {
            return redirect("/console/modifyPwd", "用户不存在,修改失败", attributes);
        }
    }


    /**
     * 首页展示数据
     *
     * @return
     */
    private Map<String, Object> getTotal() {
        Integer             userCount = userService.selectCount(new User());
        Map<String, Object> mp        = new HashMap<>(4);
        mp.put("userCount", userCount);
        mp.put("roomCount", roomService.selectCount(new Room()));
        mp.put("floorCount", floorService.selectCount(new Floor()));
        return mp;
    }

}

大家点赞、收藏、关注、评论啦 、👇🏻点开下方卡片👇🏻关注后回复 106

文章来源:https://blog.csdn.net/m0_37968982/article/details/135772572
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。