JavaWeb dormitory management system (with demo and source code download address)

Dormitory management is an important part of university management. An excellent management system can not only reduce the difficulty of dormitory management, but also reduce school management expenses to a certain extent. It can be an important symbol of building a modern university management system.

This article will take you from the construction of the operating environment, system design, system coding to the realization of the entire system, and a detailed description of the whole process. It is especially suitable for advanced project cases as a programmer, and it is also implemented by the graduation design system for college students. the best choice!

Demonstration address: Demonstration address of the dormitory management system, click me to view

1. System architecture mode

This dormitory management system adopts the B/S architecture model.

The full name of the B/S architecture is Browser/Server, that is, the browser/server structure. Browser refers to the Web browser. Compared with the C/S architecture, the B/S model has very few transaction logic implemented on the front end, and its main transaction logic is implemented on the server side. The B/S architecture system does not require special installation, only a web browser is enough.

Layering of B/S architecture:

Different from the C/S architecture with only two layers, the B/S architecture has three layers, namely:

  • The first layer of presentation layer: mainly completes the interaction between the user and the background and the output function of the final query results.
  • The second logical layer: mainly uses the server to complete the application logic function of the client.
  • The third data layer: mainly for data persistent storage.

2. Technical selection

Choosing the right technology, the whole project has been half-successful. After analyzing the system requirements and the characteristics of the system itself, plus modern B/S model mainstream architecture solutions, the system technology selection is as follows:

Data presentation layer: Html+JavaScript+CSS+VUE

Business logic layer Java+Spring+SpringMVC

Data persistence layer: MySql+MyBatis

Development tools: Eclipse

3. User analysis

This system is mainly used in college dormitory management, and the users are as follows:

  • System administrator: Manage the safe operation of the entire system and use each function.
  • Dormitory administrator: manage the dormitory and students under their own responsibility
  • Students: View browsing information, submit tasks

4. Function analysis

System administrator:

  1. Add, modify, delete announcement information
  2. Add, modify, delete dormitory administrator information
  3. Add, modify, delete student information
  4. Dormitory building management and the assignment of dormitory administrators
  5. Student dormitory management
  6. Publish attendance and clock-in tasks
  7. View and modify personal information

Insert picture description here

Dormitory administrator:

  1. View announcement
  2. View and delete students managed by yourself
  3. Add, modify, delete attendance records
  4. View student check-in records
  5. View and modify personal information

Insert picture description here

student:

  1. View announcement
  2. View attendance records
  3. Complete the check-in task and view the check-in record
  4. View and modify personal information

    Insert picture description here

5. Database design

Analyze the system requirements, the database should have the following tables:

t_admin: mainly used to store system administrator data

Field Name Types of Primary key Description
adminId int Yes Administrator Id, unique
userName varchar no username
password varchar no password
name varchar no Real name
sex varchar no gender
sex varchar no phone

t_dormbuild: Store dorm building information

Field Name Types of Primary key Description
dormBuildId int Yes Dormitory building Id, unique
dormBuildName varchar no Dormitory building name
dormBuildDetail varchar no description

t_dormmanager: mainly stores dormitory administrator information

Field Name Types of Primary key Description
dormManId varchar Yes Dormitory administrator Id, unique
userName varchar no Username, used to log in to the system
password varchar no password
dormBuildId int no Dormitory Building Id
dormBuildDetail varchar no description
name varchar no actual name
sex varchar no gender
tel varchar no phone

t_notice: used to store announcement information

Field Name Types of Primary key Description
noticeId int Yes Announcement Id, unique
noticePerson varchar no Announcer
date date no Announcement date
content varchar no Post content

t_punchclock: used to store punch clock release records

Field Name Types of Primary key Description
id int Yes Id, the only
theme varchar no Check-in theme
detail varchar no Check-in instructions
date varchar no Release date
person varchar no publisher

t_punchclockrecord: used to store punch-in information

Field Name Types of Primary key Description
id int Yes Record Id, unique
punchClock_id varchar no Punch ID
punchClock_date date no Release date
punchClock_theme varchar no Check-in theme
punchClock_detail varchar no Check-in instructions
punchClock_person varchar no publisher
name varchar no student name
dormName varchar no Bedroom number
tel varchar no Student phone
stuNum varchar no Student ID
dormBuildId int no dormitory
isRecord tinyint no Whether you have clocked in

t_record: 用于存储考勤记录

字段名称 类型 是否主键 说明
recordId int 考勤Id,唯一
studentNumber varchar 学生学号
dormBuildId int 宿舍楼
dormName varchar 寝室号
date varchar 考勤日期
detail varchar 详细说明

t_student: 学生表,用于存放学生信息

字段名称 类型 是否主键 说明
studentId int 学生Id,唯一
stuNum varchar 学号
password varchar 密码
name varchar 姓名
dormBuildId int 宿舍楼
dormName varchar 寝室号
sex varchar 性别
tel varchar 电话

6、运行环境搭建

前面已经提到,本系统使用SSM框架,搭建过程较为繁琐,因此将此部分独立出来,作为一个专题,具体搭建过程请参考《手把手教你搭建SSM框架(Eclipse版)》 这篇文章。搭建过程若出现其他问题,可以在公众号【C you again】 后台私信。

7、项目工程结构

根据第六步搭建完系统运行环境后,工程结构目录如下图所示

Insert picture description here

对工程结构各个目录的解释:

com.cya.controller

controller包用于存放接收请求的类,充当前后端数据交互的“桥梁”

Insert picture description here

com.cya.service

service包是所有业务逻辑的接口

Insert picture description here

com.cya.service.impl

service.impl包用于存放service接口的所有实现类

Insert picture description here

com.cya.mapper

mapper包用于存放对数据库操纵的接口和对应的xml实现

Insert picture description here

com.cya.entity

entity包用于存放项目中用到的所有实体类,它与数据库中的表相对应
Insert picture description here

resources文件下存放SSM框架整合的必要配置文件,详情请看《手把手教你搭建SSM框架(Eclipse版)》

Insert picture description here

dorm是存放所有model层文件的父级文件夹,其中admin,dormManager、student三个子文件夹存放系统管理员、宿舍管理员、学生三个角色对应的HTML文件。

Insert picture description here

8、功能实现及展示

由于系统包含功能众多,在此无法一一列举,所以挑选几个代表做展示,如需获取完整源码请在公众号【C you again】回复“宿舍管理系统”。

8.1 登录功能实现

项目启动成功后,在浏览器地址栏输入:http://localhost:8080/dormManage/ 进入用户登录界面如下图所示:

Insert picture description here

Insert picture description here

在此界面用户可以选择不同的角色登录,输入每个角色对应的登录信息后,首先会判断输入信息的有效性,做出相应的响应或提示。登录功能具体的实现代码如下,此处仅展示controller层代码,如下:

package com.cya.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.management.relation.Role;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.tomcat.util.digester.ArrayStack;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cya.entity.Login;
import com.cya.entity.Result;
import com.cya.service.ILoginService;
import com.cya.service.impl.LoginServiceImpl;

@Controller
@ResponseBody
public class LoginController {

    @Autowired
    private ILoginService loginServiceImpl;

    @RequestMapping("login")
    public List login(HttpServletRequest request, @RequestBody Login login) {
        List list=loginServiceImpl.login(login);
        if(list.size()==1) {
            HttpSession session=request.getSession();
            session.setAttribute(login.getRole(), list);
            System.out.println("session="+session.getAttribute(login.getRole()));
        }
        return list;
    }

    @RequestMapping("getSession")
    public List getSession(HttpServletRequest request,@RequestBody Login login){
        System.out.println(login);
        System.out.println(request.getSession().getAttribute(login.getRole()));
        List list=new ArrayList<>();
        list.add(request.getSession().getAttribute(login.getRole()));
        return list;
    }

    @RequestMapping("exitSys")
    public Result exitSys(HttpServletRequest request) {
        String exit="";
        try {
            if(request.getParameter("exit")!=null) {
                exit=request.getParameter("exit");
            }
            request.getSession().removeAttribute(exit);
            return new Result(true, "注销成功");
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
            return new Result(false, "注销失败");
        }
    }
}

8.2 发布公告功能实现

在系统管理员端,有发布公告的权限,系统管理员点击添加公告按钮,输入相关信息后进行有效性校验,校验成功及代表公告发布成功。

Insert picture description here

成功发布公告后,会出现在宿舍管理员端和学生端界面,效果图如下:

Insert picture description here

公告模块主要代码以mapper层实现为例:

 <!-- ******************** 公告 ******************* -->

  <select id="getNoticeManage" resultType="com.cya.entity.Notice">
    select * from t_notice
    <where>
      <if test="filter=='date' and key !='' ">
        date like concat("%",#{key},"%")
      </if>
    </where>
  </select>

   <insert id="addNoticeManage" parameterType="com.cya.entity.Notice">
    insert into t_notice(noticePerson,date,content) values(#{noticePerson},current_date,#{content})
  </insert>

  <select id="getNoticeMangerById" parameterType="Integer" resultType="com.cya.entity.Notice">
     select * from t_notice where noticeId=#{noticeId}
  </select>

  <update id="updataNoticeManageById" parameterType="com.cya.entity.Notice">
    update t_notice set noticePerson=#{noticePerson},content=#{content} where noticeId=#{noticeId}
  </update>

  <delete id="noticeManagerDeleteById" parameterType="Integer">

     delete from t_notice where noticeId=#{noticeId}
  </delete>

 <!-- ******************** 公告 ******************* -->

8.3 考勤记录功能实现

宿舍管理员根据自己所管理楼,对住在管理范围内的学生进行考勤,并添加考勤记录,学生端也会显示考勤信息。

Insert picture description here
主要实现代码如下:

@RequestMapping("/getRecordMsg")
    public PageResult getRecordMsg(HttpServletRequest request){
        Integer pageNum=1;
        Integer pageSize=20;
        Integer dormBuildId=0;
        String filter=request.getParameter("filter");
        String key=request.getParameter("key");
        if(request.getParameter("pageNum")!=null && request.getParameter("pageNum")!="") {
            pageNum=Integer.parseInt(request.getParameter("pageNum"));
        }
        if(request.getParameter("pageSize")!=null && request.getParameter("pageSize")!="") {
            pageSize=Integer.parseInt(request.getParameter("pageSize"));
        }
        if(request.getParameter("dormBuildId")!=null && request.getParameter("dormBuildId")!="") {
            dormBuildId=Integer.parseInt(request.getParameter("dormBuildId"));
        }
        System.out.println("pageNum="+pageNum);
        System.out.println("pageSize="+pageSize);
        return dormManageServiceImpl.getRecordMsg(pageNum, pageSize, filter, key, dormBuildId);
    }

    @RequestMapping("getRecordById")
    public Record getRecordById(Integer recordId) {
        return dormManageServiceImpl.getRecordById(recordId);
    }

    @RequestMapping("updataRecordMsg")
    public Result updataRecordMsg(@RequestBody Record record) {
        try {
            dormManageServiceImpl.updataRecordMsg(record);
            return new Result(true, "更新成功");
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
            return new Result(false, "更新失败");
        }
    }

    @RequestMapping("addRecordMsg")
    public Result addRecordMsg(@RequestBody Record record) {
        try {
            System.out.println(record);
            dormManageServiceImpl.addRecordMsg(record);
            return new Result(true, "添加成功");
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
            return new Result(false, "添加失败");
        }
    }

    @RequestMapping("recordManagerDeleteById1")
    public Result recordManagerDeleteById(HttpServletRequest request) {
        Integer recordId=0;
        if(request.getParameter("recordId")!=null && request.getParameter("recordId")!="") {
            recordId=Integer.parseInt(request.getParameter("recordId"));
        }
        try {
            dormManageServiceImpl.recordManagerDeleteById1(recordId);
            return new Result(true, "删除成功");
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
            return new Result(false, "删除失败");
        }
    }

9、源码下载

若需获取本系统源码请在公众号【C you again】回复“宿舍管理系统”

你也可以点击此链接快速回复

10、相关说明

  1. 制作不易,记得点赞+收藏+转发
  2. 本人技术有限,若有错误欢迎指正
  3. 本系统和文章均属于【C you again】原创,欢迎个人博客、各大网站转载,请注明转载地址

演示地址:宿舍管理系统演示

作者: C you again,从事软件开发 努力在IT搬砖路上的技术小白

公众号:C you again】,分享计算机类毕业设计源码、IT技术文章、游戏源码、网页模板、程序人生等等。公众号回复 【粉丝】进博主技术群,与大佬交流,领取干货学习资料

关于转载:欢迎转载博主文章,转载时表明出处

Likes link : creation is not easy, remember to like + comment + forward Thank you for your support all the way

Guess you like

Origin blog.51cto.com/15107850/2642348